Here’s a fun article on the Ruby Forum where someone provided a simple benchmarking utility. Several posters (including me) have run this to see how well Ruby runs on their system relative to other posters.
n = 1_000_000 start_time = Time.now for i in 1..n t = (1..10).inject {|x, y| x + y } end finish_time = Time.now p t puts 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"
The results are interesting… If you’re running a 3.0ghz Mac Pro you can shave about a second off of my time:
55 Ruby 1.8.6 patch 0 on i686-darwin8.9.1 It took 7.166756 seconds to run. 139533 iterations per second.
The original poster of the code didn’t fare so well
55 Ruby 1.8.6 patch 0 on i386-mswin32 It took 18.64 seconds to run. 53648 iterations per second.
How well does your system do?