[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Making Ruby faster

Yukihiro Matsumoto

2/22/2007 2:52:00 AM

Hi,

In message "Re: Making Ruby faster"
on Thu, 22 Feb 2007 11:25:10 +0900, "William James" <w_a_x_man@yahoo.com> 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

1 Answer

Alias

1/23/2013 12:10:00 AM

0

On 1/22/2013 8:50 PM, GLOBALIST wrote:
> You ask the cop to slide his badge under the door before you open it
> or to show it to you , if you have a glass in the door. He/she knows
> they must identify themselves.

Man, you're naive.

--
Alias

"Politics is the entertainment division of the Military Industrial
Complex" - Frank Zappa