Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'benchmark'
5.times do |i|
i = 10 ** i
h = Hash[i.times.map { |z| [z, z] }]
puts "N KEYS: #{i}"
puts
Benchmark.bm do |x|
x.report('dup') { 1000.times { h.dup } }
x.report('Hash[]') { 1000.times { Hash[h] } }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.