Created
February 17, 2012 19:13
-
-
Save vijaydev/1854965 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
require 'benchmark' | |
def time(times = 1) | |
unless block_given? | |
puts "No block provided" | |
return | |
end | |
ret = nil | |
Benchmark.bm do |x| | |
x.report { times.times { ret = yield } } | |
end | |
ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment