Skip to content

Instantly share code, notes, and snippets.

@mlangenberg
Created November 9, 2012 10:37
Show Gist options
  • Save mlangenberg/4045071 to your computer and use it in GitHub Desktop.
Save mlangenberg/4045071 to your computer and use it in GitHub Desktop.
def benchmark
times = 86400
Benchmark.bm do |b|
b.report("object") do
hash = {}
times.times { hash[Date.today] ||= {} }
puts hash.size
end
b.report("string") do
hash = {}
times.times { hash[Date.today.to_s] ||= {} }
puts hash.size
end
end
end
user system total real
object 1
2.730000 0.060000 2.790000 ( 2.964457)
string 1
6.770000 0.060000 6.830000 ( 7.292075)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment