Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (14 sloc) 239 Bytes
require 'benchmark/ips'
def fast
h2 = { a: 'a' }
{ one: 1, **h2 }
end
def slow
h2 = { a: 'a' }
{ one: 1 }.merge(h2)
end
Benchmark.ips do |x|
x.report('Hash#**other') { fast }
x.report('Hash#merge') { slow }
x.compare!
end
You can’t perform that action at this time.