Created
April 30, 2015 19:46
-
-
Save laurenachoo/7fc0a0c09c877d84e25b to your computer and use it in GitHub Desktop.
This file contains 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
def benchmark | |
start_time = Time.now | |
yield | |
Time.now - start_time | |
end | |
long_string = "apple"*100000000 | |
running_time = benchmark do | |
long_string.reverse | |
end | |
puts "string.reverse took #{running_time} seconds to run" | |
# Be careful, pasting this into IRB will take a long time to print. | |
# It's a loooong string. :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems more readable.