Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vijaydev
Created February 17, 2012 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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