Add benchmark for hash-fetch
Calculating ------------------------------------- fetch with no block 66979 i/100ms fetch with a block 138257 i/100ms brackets with an || 145792 i/100ms ------------------------------------------------- fetch with no block 1255521.2 (±5.2%) i/s - 6296026 in 5.028856s fetch with a block 6402972.5 (±8.1%) i/s - 31799110 in 5.002554s brackets with an || 8536511.4 (±8.1%) i/s - 42425472 in 5.005831s
This commit is contained in:
parent
0511ece2f5
commit
4e07dfef1f
|
@ -0,0 +1,9 @@
|
|||
require 'benchmark/ips'
|
||||
|
||||
h = {:bar => 'uco'}
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('fetch with no block') { h.fetch(:bar, (0..9).to_a) }
|
||||
x.report('fetch with a block') { h.fetch(:bar) { (0..9).to_a } }
|
||||
x.report('brackets with an ||') { h[:bar] || (0..9).to_a }
|
||||
end
|
Loading…
Reference in New Issue