Created
July 13, 2010 14:38
-
-
Save nicobrevin/473960 to your computer and use it in GitHub Desktop.
benchmarking with jruby
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
include java | |
def benchmark(warmups, loops, &block) | |
(0...warmups).map do | |
start_time = java.lang.System.currentTimeMillis | |
(0...loops).each { yield } | |
time = java.lang.System.currentTimeMillis - start_time | |
$stdout.write("#{time},") | |
time | |
end | |
end | |
benchmark(20, 1000) { do_something_that_hurts } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment