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

Faster changebasis #308

Merged
merged 12 commits into from
Mar 8, 2023
Merged

Faster changebasis #308

merged 12 commits into from
Mar 8, 2023

Conversation

hyrodium
Copy link
Owner

@hyrodium hyrodium commented Mar 8, 2023

Before this PR

julia> using BasicBSpline, BenchmarkTools

julia> P1 = BSplineSpace{1}(KnotVector([1, 3, 5, 8]))
BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([1, 3, 5, 8]))

julia> P2 = BSplineSpace{1}(KnotVector([1, 3, 5, 6, 8, 9]))
BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([1, 3, 5, 6, 8, 9]))

julia> @benchmark changebasis(P1, P2)
BenchmarkTools.Trial: 10000 samples with 10 evaluations.
 Range (min  max):  1.898 μs  350.734 μs  ┊ GC (min  max):  0.00%  99.22%
 Time  (median):     2.059 μs               ┊ GC (median):     0.00%
 Time  (mean ± σ):   2.501 μs ±  10.480 μs  ┊ GC (mean ± σ):  13.18% ±  3.12%

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

 Memory estimate: 4.59 KiB, allocs estimate: 51.

After this PR

julia> using BasicBSpline, BenchmarkTools

julia> P1 = BSplineSpace{1}(KnotVector([1, 3, 5, 8]))
BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([1, 3, 5, 8]))

julia> P2 = BSplineSpace{1}(KnotVector([1, 3, 5, 6, 8, 9]))
BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([1, 3, 5, 6, 8, 9]))

julia> @benchmark changebasis(P1, P2)
BenchmarkTools.Trial: 10000 samples with 78 evaluations.
 Range (min  max):  829.256 ns  39.370 μs  ┊ GC (min  max):  0.00%  96.59%
 Time  (median):     865.090 ns              ┊ GC (median):     0.00%
 Time  (mean ± σ):   993.385 ns ±  1.955 μs  ┊ GC (mean ± σ):  10.73% ±  5.31%

   ▄▇██▇▆▄▃▂▁▁                                                 ▂
  ███████████████▇▇▇▇▇▇▇███▇█▇▆▆▆▆▄▄▄▃▅▅▅▆▇▆▅▆▇▇▇▆▇▇▇▆▆▅▄▆▅▆▆▆ █
  829 ns        Histogram: log(frequency) by time      1.29 μs <

 Memory estimate: 1.81 KiB, allocs estimate: 18.

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #308 (aa47ad1) into main (068fedd) will decrease coverage by 0.06%.
The diff coverage is 98.59%.

@@            Coverage Diff             @@
##             main     #308      +/-   ##
==========================================
- Coverage   98.46%   98.41%   -0.06%     
==========================================
  Files          13       12       -1     
  Lines        1241     1263      +22     
==========================================
+ Hits         1222     1243      +21     
- Misses         19       20       +1     
Impacted Files Coverage Δ
src/_ChangeBasis.jl 97.70% <98.59%> (-0.25%) ⬇️
src/BasicBSpline.jl

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@hyrodium
Copy link
Owner Author

hyrodium commented Mar 8, 2023

Now the performance is much better:

julia> using BasicBSpline, BenchmarkTools

julia> P1 = BSplineSpace{1}(KnotVector([1, 3, 5, 8]))
BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([1, 3, 5, 8]))

julia> P2 = BSplineSpace{1}(KnotVector([1, 3, 5, 6, 8, 9]))
BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([1, 3, 5, 6, 8, 9]))

julia> @benchmark changebasis(P1, P2)
BenchmarkTools.Trial: 10000 samples with 173 evaluations.
 Range (min  max):  616.832 ns  23.942 μs  ┊ GC (min  max):  0.00%  96.58%
 Time  (median):     651.231 ns              ┊ GC (median):     0.00%
 Time  (mean ± σ):   778.790 ns ±  1.384 μs  ┊ GC (mean ± σ):  12.35% ±  6.72%

   ▅██▇▅▄▃▃▂▁▁▂▃▃▂▁                                            ▂
  █████████████████████████▇██▇▇▆▇▆▆▆▆▆▆▅▆▆▄▇▆▇▆▆▅▄▆▄▅▅▅▄▃▃▄▄▃ █
  617 ns        Histogram: log(frequency) by time      1.18 μs <

 Memory estimate: 1.28 KiB, allocs estimate: 14.

@hyrodium hyrodium merged commit e46591f into main Mar 8, 2023
@hyrodium hyrodium deleted the feature/faster_changebasis branch March 18, 2023 07:38
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