Program changed a little:

n = 3_000_000

start_time = Time.now

t = 0
1.upto(n) do |i|
  t = (1..10).inject {|x, y| x + y }
end

finish_time = Time.now

p t

puts
RUBY_VERSION ||= "unknown version"
RUBY_PATCHLEVEL ||= "unknown patchlevel"
RUBY_PLATFORM ||= "unknown platform"

print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ", 
RUBY_PLATFORM

puts
print "It took #{finish_time - start_time} seconds to run."
print " #{(n / (finish_time - start_time)).to_i} iterations per 
second.\n"


D:\>ruby calc.rb
55

Ruby 1.9.1 patch 378 on i386-mingw32
It took 6.414366 seconds to run. 467700 iterations per second.

Dell with Intel Quad Core Q6600

=================================================================

C:\>ruby19\bin\ruby.exe calc.rb
55

Ruby 1.9.1 patch 378 on i386-mingw32
It took 5.289302 seconds to run. 567182 iterations per second.

Dell with Intel i7 920, 2.67GHz

the same machine, but using Ruby 1.8.7:

Ruby 1.8.7 patch 249 on i386-mingw32
It took 20.26816 seconds to run. 148015 iterations per second.

-- 
Posted via http://www.ruby-forum.com/.