Actions
Bug #13343
closedImprove Hash#merge performance
Bug #13343:
Improve Hash#merge performance
Description
Hash#merge will be faster around 60%.
Before¶
user system total real
Hash#merge 0.160000 0.020000 0.180000 ( 0.182357)
After¶
user system total real
Hash#merge 0.110000 0.010000 0.120000 ( 0.114404)
Test code¶
require 'benchmark'
Benchmark.bmbm do |x|
hash1 = {}
100.times { |i| hash1[i.to_s] = i }
hash2 = {}
100.times { |i| hash2[(i*2).to_s] = i*2 }
x.report "Hash#merge" do
10000.times do
hash1.merge(hash2)
end
end
end
Patch¶
The patch is in https://github.com/ruby/ruby/pull/1533
Actions