Skip to content

Instantly share code, notes, and snippets.

@dsomel21
Last active June 4, 2016 17:26
Show Gist options
  • Save dsomel21/443247ef55ae590ab32e4821ca3aba6c to your computer and use it in GitHub Desktop.
Save dsomel21/443247ef55ae590ab32e4821ca3aba6c to your computer and use it in GitHub Desktop.
Simple bench mark test using ruby Time class
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