I was interested in comparing ruby speed vs python so I took the simplest recursive calculation, namely print the fibonacci sequance.
This is the python code
Here's some more numbers to compare:
Python2.7 9.67 user 0.09 system 0:09.78 elapsed 99%CPU (0avgtext+0avgdata 16560maxresident)k 0inputs+0outputs (0major+1169minor)pagefaults 0swaps ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux] 28.37 user 0.35 system 0:28.78 elapsed 99% CPU (0avgtext+0avgdata 9200maxresident)k 1896inputs+0outputs (9major+656minor)pagefaults 0swaps ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] 6.21 user 0.08 system 0:06.36 elapsed 98% CPU (0avgtext+0avgdata 14160maxresident)k 4416inputs+0outputs (16major+953minor)pagefaults 0swaps
Python is three times faster than ruby1.8 and 30% slower than ruby1.9.1 for the code provided.
Other Python versions for comparison:
2.4.6 took 10.30 seconds 2.5.5 took 9.93 seconds 2.6.6 took 9.22 seconds 2.7 took 9.35 seconds 3.0.1 took 11.67 seconds 3.1.2 took 11.35 seconds 3.2a3+ (py3k:85895, Oct 29 2010, 01:41:57) [GCC 4.4.5] took 13.09 seconds 2.5.2 (77963, Oct 15 2010, 02:00:43) [PyPy 1.3.0] took 21.26 seconds 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] took 8.81 seconds