Created
January 24, 2010 19:24
-
-
Save dydx/285390 to your computer and use it in GitHub Desktop.
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
# benchmarking.rb - Josh Sandlin - 1:58PM - 1/24/2010 | |
# benchmarking from the unofficial ruby usage guide | |
require 'benchmark' | |
include Benchmark | |
n = 1000000 | |
bm( 12 ) do |test| | |
test.report( "normal:" ) do | |
n.times do |x| | |
y = x + 1 | |
end | |
end | |
test.report( "predefine:" ) do | |
x = y = 0 | |
n.times do |x| | |
y = x + 1 | |
end | |
end | |
end | |
# ruby benchmarking.rb | |
# user system total real | |
# normal: 0.546000 0.000000 0.546000 ( 0.556000) | |
# predefine: 0.468000 0.000000 0.468000 ( 0.464000) | |
# jruby benchmarking.rb | |
# user system total real | |
# normal: 0.508000 0.000000 0.508000 ( 0.335000) | |
# predefine: 0.282000 0.000000 0.282000 ( 0.282000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment