Skip to content

Instantly share code, notes, and snippets.

@nicobrevin
Created July 13, 2010 14:38
Show Gist options
  • Save nicobrevin/473960 to your computer and use it in GitHub Desktop.
Save nicobrevin/473960 to your computer and use it in GitHub Desktop.
benchmarking with jruby
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