Skip to content

Instantly share code, notes, and snippets.

@nazgob
Created November 5, 2011 18:26
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 nazgob/1341855 to your computer and use it in GitHub Desktop.
Save nazgob/1341855 to your computer and use it in GitHub Desktop.
ruby benchmarking
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 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment