Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

18 lines (13 sloc) 210 Bytes
require 'benchmark/ips'
HASH = Hash[*('a'..'z').to_a]
def fast
Hash[HASH]
end
def slow
HASH.dup
end
Benchmark.ips do |x|
x.report("Hash[]") { fast }
x.report("Hash#dup") { slow }
x.compare!
end
You can’t perform that action at this time.