sibanu_web/public/assets/vendor/jekyll/benchmark/hash-fetch

10 lines
275 B
Plaintext
Raw Normal View History

2022-08-20 13:21:23 +07:00
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