Created
July 11, 2012 21:43
-
-
Save jelder/3093810 to your computer and use it in GitHub Desktop.
Quick and dirty Ruby benchmark method
This file contains hidden or 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
#!/usr/bin/env ruby | |
def benchmark(count) | |
timing = [] | |
count.times do | |
start = Time.now | |
yield | |
timing << Time.now - start | |
print "." | |
end | |
puts timing.inject(:+).to_f/timing.size | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment