Skip to content

Instantly share code, notes, and snippets.

@vijaydev
Created February 17, 2012 19:13
Show Gist options
  • Save vijaydev/1854965 to your computer and use it in GitHub Desktop.
Save vijaydev/1854965 to your computer and use it in GitHub Desktop.
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