ref: dry-rb/dry-validation#577
A small change on how to create the final values when requesting a complex hash.
Instead of a ruby loop, have fetch_values
call.
Case: works with a hash pointing to multiple values
Warming up --------------------------------------
current 9.893k i/100ms
original proposal 14.670k i/100ms
proposal with nil 14.260k i/100ms
Calculating -------------------------------------
current 102.132k (± 6.2%) i/s - 514.436k in 5.060271s
original proposal 166.367k (± 3.8%) i/s - 836.190k in 5.034047s
proposal with nil 159.077k (± 3.3%) i/s - 798.560k in 5.025592s
Comparison:
original proposal: 166366.9 i/s
proposal with nil: 159077.4 i/s - same-ish: difference falls within error
current: 102132.3 i/s - 1.63x slower
Case: works with a path
Warming up --------------------------------------
current 105.977k i/100ms
original proposal 108.348k i/100ms
proposal with nil 106.261k i/100ms
Calculating -------------------------------------
current 2.144M (± 4.5%) i/s - 10.704M in 5.003159s
original proposal 2.081M (± 7.0%) i/s - 10.401M in 5.027986s
proposal with nil 2.147M (± 4.2%) i/s - 10.732M in 5.008840s
Comparison:
proposal with nil: 2146594.2 i/s
current: 2144136.8 i/s - same-ish: difference falls within error
original proposal: 2080937.1 i/s - same-ish: difference falls within error
01_values.rb contains the modified versions (original_proposal
& proposal_with_nil
)
along with the current implementation([]
)
Specs:
ruby 2.4.6p354 (2019-04-01 revision 67394) [x86_64-linux]
Docker version 19.03.1, build 74b1e89
Darwin hostname 17.7.0 Darwin Kernel Version 17.7.0: Wed Apr 24 21:17:24 PDT 2019; root:xnu-4570.71.45~1/RELEASE_X86_64 x86_6