JuliaSmoothOptimizers / PartitionedVectors.jl

Other
8 stars 1 forks source link

Improve `build!` #33

Closed paraynaud closed 1 year ago

paraynaud commented 1 year ago

24

See below for the gain:

N = 1500
n = 20000
nie = 15
element_variables = map((i -> sample(1:n, nie, replace = false)), 1:N)

pv_vec = PartitionedVector(element_variables; n, simulate_vector=true)
v = [1.:n;]
set!(pv_vec, v)

@benchmark build!(pv_vec; warn=false)
# master 
# BenchmarkTools.Trial: 7563 samples with 1 evaluation.
#  Range (min … max):  546.800 μs …   2.445 ms  ┊ GC (min … max): 0.00% … 0.00%
#  Time  (median):     616.200 μs               ┊ GC (median):    0.00%
#  Time  (mean ± σ):   658.202 μs ± 135.920 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%
#   ▃███████▇▆▅▄▃▄▄▅▄▃▂▂▁▁▁▁▁▁▁ ▁▁▁ ▁▁  ▁ ▁                       ▃
#   █████████████████████████████████████████▇████▇█▇▇▇▆▇▇█▅▇▆▄▅▆ █
#   547 μs        Histogram: log(frequency) by time       1.18 ms <
#  Memory estimate: 0 bytes, allocs estimate: 0.

# current branch
# BenchmarkTools.Trial: 10000 samples with 1 evaluation.
#  Range (min … max):  28.500 μs … 218.900 μs  ┊ GC (min … max): 0.00% … 0.00%
#  Time  (median):     28.900 μs               ┊ GC (median):    0.00%
#  Time  (mean ± σ):   32.789 μs ±  13.152 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%
#   █▃▁▃▁        ▂  ▂                                            ▁
#   █████▇▇▇▇▆▅▄▆█▇██▇▅▄▅▅▄▃▄▄▅▇█████▆▆▆▅▅▅▅▅▆▅▁▃▁▃▄▄▁▁▁▁▁▁▄▆▆▆▆ █
#   28.5 μs       Histogram: log(frequency) by time       106 μs <
#  Memory estimate: 0 bytes, allocs estimate: 0.
codecov[bot] commented 1 year ago

Codecov Report

Base: 99.07% // Head: 99.07% // Decreases project coverage by -0.00% :warning:

Coverage data is based on head (20a4387) compared to base (c187ff4). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #33 +/- ## ========================================== - Coverage 99.07% 99.07% -0.01% ========================================== Files 6 6 Lines 217 216 -1 ========================================== - Hits 215 214 -1 Misses 2 2 ``` | [Impacted Files](https://codecov.io/gh/JuliaSmoothOptimizers/PartitionedVectors.jl/pull/33?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaSmoothOptimizers) | Coverage Δ | | |---|---|---| | [src/struct.jl](https://codecov.io/gh/JuliaSmoothOptimizers/PartitionedVectors.jl/pull/33/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaSmoothOptimizers#diff-c3JjL3N0cnVjdC5qbA==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaSmoothOptimizers). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaSmoothOptimizers)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.