Revision 687785a00d665f3a134b28fcd2b3d0260e27c510 authored by Parker Moore on 03 August 2020, 20:29:36 UTC, committed by Parker Moore on 03 August 2020, 20:29:36 UTC
1 parent ac7b264
hash-fetch
#!/usr/bin/env ruby
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
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...