JuliaActuary / MortalityTables.jl

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

Add Parsing of CSV format #79

Closed alecloudenback closed 4 years ago

alecloudenback commented 4 years ago

Still needs:

codecov[bot] commented 4 years ago

Codecov Report

Merging #79 into master will decrease coverage by 0.15%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
- Coverage   98.25%   98.09%   -0.16%     
==========================================
  Files           7        8       +1     
  Lines         286      263      -23     
==========================================
- Hits          281      258      -23     
  Misses          5        5              
Flag Coverage Δ
#unittests 98.09% <100.00%> (-0.16%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/MortalityTables.jl 100.00% <ø> (ø)
src/CSV.jl 100.00% <100.00%> (ø)
src/MortalityTable.jl 97.43% <0.00%> (-0.68%) :arrow_down:
src/parameterized_models.jl 97.47% <0.00%> (-0.58%) :arrow_down:
src/XTbML.jl 98.07% <0.00%> (-0.37%) :arrow_down:
src/get_SOA_table.jl 100.00% <0.00%> (ø)

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 876707d...48b5660. Read the comment docs.

alecloudenback commented 4 years ago

Benchmarks indicate roughly 20x faster than XTbML format:

julia> @benchmark MortalityTables.readcsv($csvp)
BenchmarkTools.Trial: 
  memory estimate:  332.75 KiB
  allocs estimate:  7775
  --------------
  minimum time:     763.600 μs (0.00% GC)
  median time:      795.500 μs (0.00% GC)
  mean time:        885.834 μs (4.04% GC)
  maximum time:     15.392 ms (88.53% GC)
  --------------
  samples:          5613
  evals/sample:     1
julia> @benchmark MortalityTables.readXTbML($xp)
BenchmarkTools.Trial: 
  memory estimate:  6.08 MiB
  allocs estimate:  143633
  --------------
  minimum time:     13.596 ms (0.00% GC)
  median time:      14.740 ms (0.00% GC)
  mean time:        17.260 ms (5.93% GC)
  maximum time:     38.174 ms (18.67% GC)
  --------------
  samples:          290
  evals/sample:     1
alecloudenback commented 4 years ago

Seems like the tradeoff to switch to CSVs primarily will be longer precompile times:

julia> @time using XMLDict
[ Info: Precompiling XMLDict [228000da-037f-5747-90a9-8195ccbf91a5]
  1.546263 seconds (1.01 M allocations: 55.651 MiB, 0.49% gc time)
julia> @time using CSV
[ Info: Precompiling CSV [336ed68f-0bac-5ca0-87d4-7b16caf5d00b]
 21.197266 seconds (8.65 M allocations: 460.424 MiB, 0.48% gc time)