Last year, I compared Ruby 1.8.7 with Ruby 1.9.1 by running the code I wrote to solve the MEC problem in ruby. Here I repeat the runs using more of the ruby versions supported by RVM. Note that I put "Real World" in quotes for a reason: this is benchmarking one script that is very much CPU bound. If your specific solution is not CPU bound, you WILL get different results. If your test bed is not my crappy Gateway laptop, you WILL get different results. My point is: don't get hung up on benchmarks. All this post is saying is that one specific program runs more or less quickly on my laptop when using different versions of the Ruby interpreter. I find comparing the time of execution between the different versions useful. You might not.

My observations: JRuby looks very promising, especially if you let it run for a while. This gives the JIT compiler time to kick in and really speed things up. MRI 1.9.2 looks equally promising. A 30% improvement in speed over 1.9.1. I expected more out of rubinius. Maybe rc3 will be better?

My Platform:

$ uname -a
Linux nuk 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 02:39:34 UTC 2010 x86_64 GNU/Linux

The Results:

$ rvm ruby mec.rb benchmark

jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_16) [amd64-java]

                     user     system      total        real
points: 1        0.539000   0.000000   0.539000 (  0.149000)
points: 10       1.164000   0.000000   1.164000 (  1.164000)
points: 100      3.802000   0.000000   3.802000 (  3.802000)
points: 1000     6.446000   0.000000   6.446000 (  6.446000)
points: 10000   61.596000   0.000000  61.596000 ( 61.596000)

rbx-1.0.0-rc2: rubinius 1.0.0-rc2 (1.8.7 release 2010-01-04 JI) [x86_64-unknown-linux-gnu] 

                     user     system      total        real
points: 1        0.075468   0.000000   0.075468 (  0.075413)
points: 10       0.286978   0.000000   0.286978 (  0.286989)
points: 100      3.721381   0.000000   3.721381 (  3.721394)
points: 1000    16.345301   0.000000  16.345301 ( 16.345368)
points: 10000  163.513582   0.000000 163.513582 (163.513664)

ree-1.8.7-2010.01: ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2010.01 

                     user     system      total        real
points: 1        0.000000   0.010000   0.010000 (  0.001846)
points: 10       0.040000   0.000000   0.040000 (  0.056238)
points: 100      0.690000   0.000000   0.690000 (  0.734812)
points: 1000     7.740000   0.050000   7.790000 (  8.973666)
points: 10000  113.350000   0.370000 113.720000 (123.330263)

ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] 

                     user     system      total        real
points: 1        0.000000   0.000000   0.000000 (  0.001856)
points: 10       0.040000   0.000000   0.040000 (  0.041965)
points: 100      0.560000   0.010000   0.570000 (  0.654654)
points: 1000     9.510000   0.020000   9.530000 ( 10.345083)
points: 10000  168.130000   0.660000 168.790000 (186.113405)

ruby-1.9.1-p378: ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux] 

                     user     system      total        real
points: 1        0.000000   0.000000   0.000000 (  0.001709)
points: 10       0.040000   0.000000   0.040000 (  0.049836)
points: 100      0.790000   0.020000   0.810000 (  0.813920)
points: 1000     6.890000   0.030000   6.920000 (  7.197953)
points: 10000  106.450000   0.410000 106.860000 (115.479498)

ruby-1.9.2-preview1: ruby 1.9.2dev (2009-07-18 trunk 24186) [x86_64-linux] 

                     user     system      total        real
points: 1        0.000000   0.000000   0.000000 (  0.001840)
points: 10       0.020000   0.000000   0.020000 (  0.046297)
points: 100      0.400000   0.010000   0.410000 (  0.442191)
points: 1000     5.140000   0.010000   5.150000 (  5.480616)
points: 10000   66.470000   0.330000  66.800000 ( 79.445442)

To appease the jruby folks, I reran the jruby test using some JVM flags that are supposed to speed things up. The results are even better.

$ jruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m -J-server -J-Djruby.compile.mode=JIT mec.rb benchmark
                     user     system      total        real
points: 1        0.588000   0.000000   0.588000 (  0.190000)
points: 10       1.209000   0.000000   1.209000 (  1.208000)
points: 100      4.047000   0.000000   4.047000 (  4.047000)
points: 1000     7.064000   0.000000   7.064000 (  7.064000)
points: 10000   43.832000   0.000000  43.832000 ( 43.832000)