View Single Post
Old Feb 26th, 2007, 7:57 PM   #1
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4 Jessehk is on a distinguished road
Ruby speed improvements with YARV

In case you didn't know, a new virtual machine for Ruby called YARV (Yet Another Ruby VM) has been integrated into testing for Ruby 1.9.

In my own (very informal) testing, I've gotten speed ups of 2x to about 8x.
You can download it from the ruby-lang.org website.

Also, take a glance at this page for some benchmarks. http://www.antoniocangiano.com/artic...us-vs-cardinal




EDIT: I thought I'd add a little example.

ruby Syntax (Toggle Plain Text)
  1. def fib(n)
  2. if n < 3
  3. 1
  4. else
  5. fib(n - 1) + fib(n - 2)
  6. end
  7. end
  8.  
  9. fib(34)

python Syntax (Toggle Plain Text)
  1. def fib(n):
  2. if n < 3:
  3. return 1
  4. else:
  5. return fib(n - 1) + fib(n - 2)
  6.  
  7. fib(34)

Ruby 1.8.5
$ time ruby fib.rb

real    0m15.306s
user    0m13.273s
sys     0m1.984s

Python 2.4.4
$ time python fib.py

real    0m6.857s
user    0m6.736s
sys     0m0.036s

Ruby 1.9 (2007 - 02 - 25)
$ time /usr/local/src/ruby/ruby fib.rb

real    0m2.048s
user    0m2.012s
sys     0m0.016s
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!

Last edited by Jessehk; Feb 26th, 2007 at 8:09 PM.
Jessehk is offline   Reply With Quote