JuliaActuary / MortalityTables.jl

Easily Reference and use Actuarial Mortality Tables
https://juliaactuary.github.io/MortalityTables.jl/stable
Other
28 stars 10 forks source link

reduce allocations by not broadcasting (+ formatting/spelling) #117

Closed alecloudenback closed 2 years ago

alecloudenback commented 2 years ago

Before

julia> @benchmark survival($t.ultimate,50,80)
BenchmarkTools.Trial: 10000 samples with 991 evaluations.
 Range (min … max):  40.448 ns … 420.240 ns  ┊ GC (min … max): 0.00% … 85.84%
 Time  (median):     43.769 ns               ┊ GC (median):    0.00%
 Time  (mean ± σ):   46.705 ns ±  26.898 ns  ┊ GC (mean ± σ):  4.40% ±  6.76%

       ▃██▆▃                                                    
  ▂▂▂▂▆██████▅▅▅▄▃▃▃▃▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ ▃
  40.4 ns         Histogram: frequency by time           65 ns <

 Memory estimate: 304 bytes, allocs estimate: 1.

After

 julia> @benchmark survival($t.ultimate,50,80)
BenchmarkTools.Trial: 10000 samples with 997 evaluations.
 Range (min … max):  21.648 ns … 38.824 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     21.858 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   22.063 ns ±  0.745 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

   ▃███▅▂▁      ▁▂▂▃▁▁         ▂▁▂  ▁                         ▂
  ▇███████▆▇▅▅▆▄██████▇██▇█▆▇▇▆██████▇▇▃▆▅▅▅▃▄▃▄▁▃▅▃▃▄▁▁▄▄▃▄▅ █
  21.6 ns      Histogram: log(frequency) by time      25.1 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.
codecov[bot] commented 2 years ago

Codecov Report

Merging #117 (462432f) into master (171fa69) will decrease coverage by 0.19%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #117      +/-   ##
==========================================
- Coverage   90.16%   89.97%   -0.20%     
==========================================
  Files           9        9              
  Lines         366      369       +3     
==========================================
+ Hits          330      332       +2     
- Misses         36       37       +1     
Impacted Files Coverage Δ
src/MortalityTable.jl 96.55% <100.00%> (-1.64%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 171fa69...462432f. Read the comment docs.