Skip to content

Instantly share code, notes, and snippets.

@ybakos
Created August 29, 2009 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ybakos/177591 to your computer and use it in GitHub Desktop.
Save ybakos/177591 to your computer and use it in GitHub Desktop.
require 'benchmark'
n = 100000
Benchmark.bm do |x|
x.report('copy') { n.times do ; h = {}; h = h.merge({1 => 2}); end }
x.report('no copy') { n.times do ; h = {}; h.merge!({1 => 2}); end }
x.report('aha') { n.times do; puts 'your shit here'; end }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment