Quick numerical benchmark of Ruby 1.9

November 28, 2007

I was looking for something to run to try to put the current Ruby 1.9 through its paces. The first code I found was this

total = 0.0

1.0.step(2000.0,0.0001) do |x|

  result = (5.4*x**5 - 3.211*x**4 + 100.3*x**2 - 100 +
    20*Math.sin(x) - Math.log(x)) * 20*Math.exp(-x/100.3)
  total += result / 0.0001


puts total

Its heavy on the floating point that’s what I mostly use; ‘normal’ use is more likely integer math. Its a nonsensical calculation that I should rework as a real integration problem…

Timings (intel iMac)

imac:$ time ruby pure_ruby.rb

real    1m43.283s
user    1m38.615s
sys     0m1.213s
imac:$ time /usr/local/ruby1.9/bin/ruby pure_ruby.rb

real    1m1.352s
user    0m58.550s
sys     0m0.749s

Which is 1.7x faster. Not bad for no additional work. These numbers are very preliminary, and shouldn’t be mistaken for real benchmarks. I have a series of tests I did with pair correlation function calculations on a simulated liquid that I want to rerun and see how 1.9 holds up.


Performance in Ruby 1.9

November 27, 2007

Ruby logoI have seen some rumblings about Ruby 1.9 being almost ready (here’s hoping that it turns out better than this years OS upgrades) and faster than before. I haven’t looked at 1.9 since I ran some of my early benchmarks.

How To Start Playing With Ruby 1.9 Right Now!

More Real World Performance Data

Changes in Ruby 1.9