Skip to content
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 on changebasis_I #347

Merged
merged 11 commits into from
Dec 10, 2023

Conversation

hyrodium
Copy link
Owner

@hyrodium hyrodium commented Dec 9, 2023

Before this PR

julia> using BasicBSpline, BenchmarkTools

julia> P = BSplineSpace{3}(KnotVector(1:10))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

julia> P′ = BSplineSpace{3}(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_I(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_I(P, P′)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min  max):  25.378 μs    3.890 ms  ┊ GC (min  max): 0.00%  97.68%
 Time  (median):     28.083 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   33.081 μs ± 110.248 μs  ┊ GC (mean ± σ):  9.78% ±  2.91%

   ▁▄▆██▇▆▄▃▁▂▃▄▄▄▄▃▂▁▁▁▁▁      ▁                              ▂
  ▆██████████████████████████████████▇▇▆▇▆▆▆▅▆▅▆▅▅▃▄▅▄▅▅▃▅▂▄▂▅ █
  25.4 μs       Histogram: log(frequency) by time      52.1 μs <

 Memory estimate: 40.55 KiB, allocs estimate: 508.

julia> P = BSplineSpace{2}(knotvector"3 113")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 3, 4, 5, 5, 5]))

julia> P′ = BSplineSpace{3}(knotvector"4 324")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 3, 3, 3, 4, 4, 5, 5, 5, 5]))

julia> changebasis_I(P, P′)
5×9 SparseArrays.SparseMatrixCSC{Float64, Int32} with 16 stored entries:
 1.0  0.333333                                                          
     0.666667  0.777778  0.333333  0.111111                               
              0.222222  0.666667  0.888889  0.833333  0.166667             
                                         0.166667  0.833333  0.666667    
                                                           0.333333  1.0

julia> @benchmark changebasis_I(P, P′)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min  max):  15.930 μs   4.208 ms  ┊ GC (min  max): 0.00%  97.75%
 Time  (median):     17.473 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   19.979 μs ± 75.837 μs  ┊ GC (mean ± σ):  7.42% ±  1.95%

     ▄▇█▆▃                                                     
  ▁▂▆██████▅▄▂▂▂▂▃▂▃▃▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  15.9 μs         Histogram: frequency by time        29.5 μs <

 Memory estimate: 25.95 KiB, allocs estimate: 311.

After this PR

julia> using BasicBSpline, BenchmarkTools

julia> P = BSplineSpace{3}(KnotVector(1:10))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

julia> P′ = BSplineSpace{3}(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_I(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_I(P, P′)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min  max):  22.683 μs   3.696 ms  ┊ GC (min  max): 0.00%  96.94%
 Time  (median):     24.937 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   28.890 μs ± 95.613 μs  ┊ GC (mean ± σ):  8.57% ±  2.57%

   ▂▄▇███▇▅▄▂▂▁▁▃▃▄▄▃▃▂▂▂▂▂▁▁▁▁▁▁                             ▂
  ▆████████████████████████████████▇▇▆▇▇▇▇▆▇▅▆▇▅▅▅▅▅▆▄▂▄▃▅▂▄▄ █
  22.7 μs      Histogram: log(frequency) by time        44 μs <

 Memory estimate: 33.38 KiB, allocs estimate: 393.

julia> P = BSplineSpace{2}(knotvector"3 113")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 3, 4, 5, 5, 5]))

julia> P′ = BSplineSpace{3}(knotvector"4 324")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 3, 3, 3, 4, 4, 5, 5, 5, 5]))

julia> changebasis_I(P, P′)
5×9 SparseArrays.SparseMatrixCSC{Float64, Int32} with 16 stored entries:
 1.0  0.333333                                                          
     0.666667  0.777778  0.333333  0.111111                               
              0.222222  0.666667  0.888889  0.833333  0.166667             
                                         0.166667  0.833333  0.666667    
                                                           0.333333  1.0

julia> @benchmark changebasis_I(P, P′)
BenchmarkTools.Trial: 10000 samples with 9 evaluations.
 Range (min  max):  2.528 μs  351.001 μs  ┊ GC (min  max): 0.00%  97.00%
 Time  (median):     2.714 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   3.137 μs ±   9.145 μs  ┊ GC (mean ± σ):  8.05% ±  2.74%

  ▁▆██▇▆▅▃▂▁          ▁▁▁▁▁▁▁▁▁▁ ▁                            ▂
  ██████████▇▆▇▆████████████████▇█▇▆▆▆▇▆▇▆▆▆▅▇▅▆▅▅▅▅▂▅▅▅▅▅▄▄▄ █
  2.53 μs      Histogram: log(frequency) by time      5.31 μs <

 Memory estimate: 4.88 KiB, allocs estimate: 52.

Copy link

codecov bot commented Dec 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6a0cb27) 96.13% compared to head (8f8c110) 96.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #347      +/-   ##
==========================================
- Coverage   96.13%   96.07%   -0.06%     
==========================================
  Files          14       14              
  Lines        1603     1606       +3     
==========================================
+ Hits         1541     1543       +2     
- Misses         62       63       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hyrodium hyrodium changed the title More performance on changebasis_i More performance on changebasis_I Dec 9, 2023
@hyrodium hyrodium merged commit ab56581 into main Dec 10, 2023
12 of 13 checks passed
@hyrodium hyrodium deleted the feature/more_performance_on_changebasis_I branch December 11, 2023 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant