Last active
April 14, 2016 18:21
-
-
Save bryanp/6f54a53a0eff4d2ed8dbfcc10833b093 to your computer and use it in GitHub Desktop.
Ruby Benchmark Quiz
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
# Comment with what benchmark you think would be faster, and why. | |
require "benchmark" | |
data = { | |
'foo' => 'bar' | |
} | |
count = 100_000_000 | |
time = Benchmark.measure do | |
count.times do | |
data['foo'] | |
end | |
end | |
puts time | |
key = 'foo' | |
time = Benchmark.measure do | |
count.times do | |
data[key] | |
end | |
end | |
puts time |
iamvery
commented
Apr 14, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment