-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More performance #344
Merged
Merged
More performance #344
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## main #344 +/- ##
==========================================
- Coverage 96.56% 96.43% -0.14%
==========================================
Files 14 14
Lines 1574 1571 -3
==========================================
- Hits 1520 1515 -5
- Misses 54 56 +2
|
Before this PR julia> using BasicBSpline, BenchmarkTools
julia> P6 = BSplineSpace{2}(knotvector"1111 111")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 6, 7, 8]))
julia> P7 = BSplineSpace{2}(knotvector"11121111")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 4, 5, 6, 7, 8]))
julia> P6 ⊆ P7
true
julia> P6 ⊑ P7
true
julia> @benchmark P6 ⊆ P7
BenchmarkTools.Trial: 10000 samples with 996 evaluations.
Range (min … max): 23.789 ns … 53.344 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 24.173 ns ┊ GC (median): 0.00%
Time (mean ± σ): 24.400 ns ± 1.360 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▇▅▃▂▁ ▂
███████▅▅▄▃▁▄▅▄▅▅▅▇▆▆▇▅▆▃▅▅▄▃▄▄▁▁▁▁▃▁▁▃▁▃▃▁▁▁▁▁▁▁▁▁▁▁▁▁▃▁▁▅ █
23.8 ns Histogram: log(frequency) by time 35.5 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark P6 ⊑ P7
BenchmarkTools.Trial: 10000 samples with 301 evaluations.
Range (min … max): 291.714 ns … 12.953 μs ┊ GC (min … max): 0.00% … 95.71%
Time (median): 316.198 ns ┊ GC (median): 0.00%
Time (mean ± σ): 379.197 ns ± 800.701 ns ┊ GC (mean ± σ): 14.42% ± 6.62%
▁▄▇█▇▄
▁▂▃▆███████▅▃▂▂▂▂▂▂▁▁▁▁▂▂▂▃▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
292 ns Histogram: frequency by time 478 ns <
Memory estimate: 752 bytes, allocs estimate: 9. After this PR julia> using BasicBSpline, BenchmarkTools
julia> P6 = BSplineSpace{2}(knotvector"1111 111")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 6, 7, 8]))
julia> P7 = BSplineSpace{2}(knotvector"11121111")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 4, 5, 6, 7, 8]))
julia> P6 ⊆ P7
true
julia> P6 ⊑ P7
true
julia> @benchmark P6 ⊆ P7
BenchmarkTools.Trial: 10000 samples with 996 evaluations.
Range (min … max): 23.126 ns … 47.963 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 23.660 ns ┊ GC (median): 0.00%
Time (mean ± σ): 24.191 ns ± 2.216 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▄▆█▇▃▂▂ ▂ ▂
███████▇▆█▆▅▅▆▇▇▇▇▇▆▇▆▆▆▆▆▅▃▄▄▃▅▁▃▄▁▄▃▅▄▁▃▃▃▃▁▁▃▁▁▃▄▁▄██▅█▇ █
23.1 ns Histogram: log(frequency) by time 35.1 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark P6 ⊑ P7
BenchmarkTools.Trial: 10000 samples with 996 evaluations.
Range (min … max): 23.187 ns … 41.766 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 23.670 ns ┊ GC (median): 0.00%
Time (mean ± σ): 24.101 ns ± 1.958 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▃▇██▃▁ ▂▁▁ ▂
██████▅▅▄▅▅▅▅▆▆▆▇▇█▆▇▆▆▇▅▆▅▆▅▅▄▅▁▃▃▁▁▃▄▃▄▃▁▄▁▁▁▄▄▃▄▆▇▇█████ █
23.2 ns Histogram: log(frequency) by time 33.1 ns <
Memory estimate: 0 bytes, allocs estimate: 0. |
Still can be improved, but getting better. Before this PR julia> using BasicBSpline, BenchmarkTools
julia> p = 3
3
julia> P = BSplineSpace{p}(KnotVector(1:10))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
julia> P′ = BSplineSpace{p}(KnotVector([1,2,3,4,4.5,5,6,7,8.1,9.1,10.5]))
BSplineSpace{3, Float64, KnotVector{Float64}}(KnotVector([1.0, 2.0, 3.0, 4.0, 4.5, 5.0, 6.0, 7.0, 8.1, 9.1, 10.5]))
julia> changebasis(P,P′)
6×7 SparseArrays.SparseMatrixCSC{Float64, Int32} with 13 stored entries:
1.0 0.166667 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 0.833333 0.5 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 0.5 0.833333 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 0.166667 1.0 -0.0333333 0.0183333
⋅ ⋅ ⋅ ⋅ ⋅ 1.03333 -0.103333
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.085
julia> @benchmark changebasis(P,P′)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 214.406 μs … 3.984 ms ┊ GC (min … max): 0.00% … 92.05%
Time (median): 222.922 μs ┊ GC (median): 0.00%
Time (mean ± σ): 254.091 μs ± 320.269 μs ┊ GC (mean ± σ): 11.10% ± 8.23%
▁▃▅▇██▇▆▄▃▃▃▃▂▂▂▁ ▂
▅███████████████████▇▇▆▇▇▅▅▆▆▆▇▄▆▆▆▆▅▆▄▆▅▅▆▃▃▂▂▄▃▄▅▄▅▅▆▅▆▆▅▅▅ █
214 μs Histogram: log(frequency) by time 295 μs <
Memory estimate: 363.89 KiB, allocs estimate: 4150. After this PR julia> using BasicBSpline, BenchmarkTools
julia> p = 3
3
julia> P = BSplineSpace{p}(KnotVector(1:10))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
julia> P′ = BSplineSpace{p}(KnotVector([1,2,3,4,4.5,5,6,7,8.1,9.1,10.5]))
BSplineSpace{3, Float64, KnotVector{Float64}}(KnotVector([1.0, 2.0, 3.0, 4.0, 4.5, 5.0, 6.0, 7.0, 8.1, 9.1, 10.5]))
julia> changebasis(P,P′)
6×7 SparseArrays.SparseMatrixCSC{Float64, Int32} with 13 stored entries:
1.0 0.166667 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 0.833333 0.5 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 0.5 0.833333 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 0.166667 1.0 -0.0333333 0.0183333
⋅ ⋅ ⋅ ⋅ ⋅ 1.03333 -0.103333
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.085
julia> @benchmark changebasis(P,P′)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 26.300 μs … 4.336 ms ┊ GC (min … max): 0.00% … 97.00%
Time (median): 28.945 μs ┊ GC (median): 0.00%
Time (mean ± σ): 34.048 μs ± 118.740 μs ┊ GC (mean ± σ): 10.23% ± 2.92%
▄██▅▃
▁▂▃▇█████▇▅▃▂▂▂▂▄▅▆▆▅▄▃▃▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
26.3 μs Histogram: frequency by time 45.3 μs <
Memory estimate: 40.86 KiB, allocs estimate: 508. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #333
Before this PR
After this PR