Created
February 18, 2015 15:24
-
-
Save tiegz/c697f09d645a4e609958 to your computer and use it in GitHub Desktop.
Hash#dup/clone benches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
GC.disable | |
x = {:a => 1} | |
ms1 = 1000 * Benchmark.realtime { 1_000_000.times { x.dup } } | |
ms2 = 1000 * Benchmark.realtime { 1_000_000.times { x.clone } } | |
puts [ | |
"#{RUBY_ENGINE rescue 'ruby'} #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}...".ljust(30), | |
ms1.to_i.to_s.rjust(10) + "ms", | |
ms2.to_i.to_s.rjust(10) + "ms" | |
].join('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment