From: Yukihiro Matsumoto Date: 2007-02-22T11:51:50+09:00 Subject: Re: Making Ruby faster Hi, In message "Re: Making Ruby faster" on Thu, 22 Feb 2007 11:25:10 +0900, "William James" writes: |3% is a modest improvment. Let's see what can be |achieved by switching to a language that's designed |to be fast. | | Ruby Lua LuaJIT |------------------------------ |tarai 0% 408% 1918% |fib 0% 497% 2874% |mandelbrot 0% 920% 1347% Here's my numbers, meaningful or not: Ruby YARV ----------------------- tarai 0% 547% fib 0% 540% mandelbrot 0% 172% total 0% 472% ----------------------- def tarai( x, y, z ) if x <= y then return y else return tarai( tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y)) end end p tarai(12, 6, 0) ##### def fib( n ) if n < 3 then return 1 else return fib(n-1) + fib(n-2) end end p fib(12) ##### include Math def c_mul( c1, c2 ) a,b = c1 c,d = c2 return a*c - b*d, a*d + c*b end def c_abs(c) a, b = c return sqrt( a*a + b*b ) end def is_mandelbrot( z ) for i in 1..100 do z = c_mul( z, z ) if c_abs( z ) > 2 then return false end end return true end ary = [] for xx in 0..100 do for yy in 0..100 do c = [xx / 50.0, yy / 50.0] if is_mandelbrot( c ) then ary.push(c) end end end