Last active
June 4, 2016 17:26
-
-
Save dsomel21/443247ef55ae590ab32e4821ca3aba6c to your computer and use it in GitHub Desktop.
Simple bench mark test using ruby Time class
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 | |
# Initialize the times | |
start_time = Time.now | |
yield | |
end_time = Time.now | |
running_time = end_time - start_time | |
puts "string.reverse took #{running_time} seconds to run" | |
end | |
benchmark { | |
long_string = "apple"*1000000 | |
long_string.reverse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment