[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: How fast does your Ruby run?

Felix Windt

9/24/2007 12:58:00 AM

> -----Original Message-----
> From: M. Edward (Ed) Borasky [mailto:znmeb@cesmail.net]
> Sent: Sunday, September 23, 2007 5:32 PM
> To: ruby-talk ML
> Subject: Re: How fast does your Ruby run?
>
> Lloyd Linklater wrote:
> > SpringFlowers AutumnMoon wrote:
> >> The performance gain I got from Ruby 1.8.6 to Ruby 1.9 is
> only from
> >> about 52,000 iterations per second to 58,000... I wonder why other
> >> people get so big performance gain instead. is it because
> they compile
> >> their only Ruby 1.9.
> >
> > If that is true, then is the release version specifically
> compiled to be
> > slow? Which compiler is the best and which settings to use
> for a "roll
> > your own" ruby for windows? Unix?
> >
>
> As far as I've been able to determine, with gcc, the compiler settings
> should be "-O3 -march=<architecture>", where <architecture>
> is the chip
> name, for example "-O3 -march=athlon64". There doesn't seem to be much
> gain from going from O2 to O3, but it's non-zero. The tests
> I've looked
> at indicate that it's the "-march" piece that does the real job.
> Incidentally, I saw a post go by somewhere that had "-march= -mcpu=
> -mtune=" flags all set. The only one you want is "-march" --
> the others
> are redundant or ignored or both.
>
> See http://www.jhaampe.org/softwar... for the details.
>
> I can't help you with the Microsoft or other Windows compilers. Cygwin
> or MSYS/MinGW compiling, on the other hand, should work the
> same way as
> Linux -- you've got gcc, so use "-march=" and "-O3".
>


Just for the hell of it, on a Core 2 Duo @ 2GhZ:


Vanilla Ubuntu Ruby from repositories
$ ruby test.rb
Ruby 1.8.5 on i486-linux
It took 20.8315 seconds to run. 48004 iterations per second.


Standard compiled from source (no compiler flags)
$ ./ruby1.8.6/bin/ruby test.rb
Ruby 1.8.6 on i686-linux
It took 7.015534 seconds to run. 142540 iterations per second.


Optimized compiled from source (CFLAGS="-O3 -march=nocona")
$ ./ruby1.8.6opt/bin/ruby test.rb
Ruby 1.8.6 on i686-linux
It took 6.543835 seconds to run. 152815 iterations per second.


Vanilla Ubuntu Ruby 1.9 from repositories
$ ruby1.9 test.rb
Ruby 1.9.0 on i486-linux
It took 24.726563 seconds to run. 40442 iterations per second.


Standard 1.9 compiled from source (no compiler flags)
$ ./ruby1.9/bin/ruby test.rb
Ruby 1.9.0 on i686-linux
It took 2.627064 seconds to run. 380653 iterations per second.


Optimized 1.9 compiled from source (CFLAGS="-O3 -march=nocona")
felix@felix-laptop:~$ ./ruby1.9opt/bin/ruby test.rb
Ruby 1.9.0 on i686-linux
It took 2.593149 seconds to run. 385631 iterations per second.


Felix
1 Answer

M. Edward (Ed) Borasky

9/24/2007 1:50:00 AM

0

Felix Windt wrote:
>> -----Original Message-----
>> From: M. Edward (Ed) Borasky [mailto:znmeb@cesmail.net]
>> Sent: Sunday, September 23, 2007 5:32 PM
>> To: ruby-talk ML
>> Subject: Re: How fast does your Ruby run?
>>
>> Lloyd Linklater wrote:
>>> SpringFlowers AutumnMoon wrote:
>>>> The performance gain I got from Ruby 1.8.6 to Ruby 1.9 is
>> only from
>>>> about 52,000 iterations per second to 58,000... I wonder why other
>>>> people get so big performance gain instead. is it because
>> they compile
>>>> their only Ruby 1.9.
>>> If that is true, then is the release version specifically
>> compiled to be
>>> slow? Which compiler is the best and which settings to use
>> for a "roll
>>> your own" ruby for windows? Unix?
>>>
>> As far as I've been able to determine, with gcc, the compiler settings
>> should be "-O3 -march=<architecture>", where <architecture>
>> is the chip
>> name, for example "-O3 -march=athlon64". There doesn't seem to be much
>> gain from going from O2 to O3, but it's non-zero. The tests
>> I've looked
>> at indicate that it's the "-march" piece that does the real job.
>> Incidentally, I saw a post go by somewhere that had "-march= -mcpu=
>> -mtune=" flags all set. The only one you want is "-march" --
>> the others
>> are redundant or ignored or both.
>>
>> See http://www.jhaampe.org/softwar... for the details.
>>
>> I can't help you with the Microsoft or other Windows compilers. Cygwin
>> or MSYS/MinGW compiling, on the other hand, should work the
>> same way as
>> Linux -- you've got gcc, so use "-march=" and "-O3".
>>
>
>
> Just for the hell of it, on a Core 2 Duo @ 2GhZ:
>
>
> Vanilla Ubuntu Ruby from repositories
> $ ruby test.rb
> Ruby 1.8.5 on i486-linux
> It took 20.8315 seconds to run. 48004 iterations per second.
>
>
> Standard compiled from source (no compiler flags)
> $ ./ruby1.8.6/bin/ruby test.rb
> Ruby 1.8.6 on i686-linux
> It took 7.015534 seconds to run. 142540 iterations per second.
>
>
> Optimized compiled from source (CFLAGS="-O3 -march=nocona")
> $ ./ruby1.8.6opt/bin/ruby test.rb
> Ruby 1.8.6 on i686-linux
> It took 6.543835 seconds to run. 152815 iterations per second.
>
>
> Vanilla Ubuntu Ruby 1.9 from repositories
> $ ruby1.9 test.rb
> Ruby 1.9.0 on i486-linux
> It took 24.726563 seconds to run. 40442 iterations per second.
>
>
> Standard 1.9 compiled from source (no compiler flags)
> $ ./ruby1.9/bin/ruby test.rb
> Ruby 1.9.0 on i686-linux
> It took 2.627064 seconds to run. 380653 iterations per second.
>
>
> Optimized 1.9 compiled from source (CFLAGS="-O3 -march=nocona")
> felix@felix-laptop:~$ ./ruby1.9opt/bin/ruby test.rb
> Ruby 1.9.0 on i686-linux
> It took 2.593149 seconds to run. 385631 iterations per second.
>
>
> Felix

Yep ... those numbers are typical of what I'm seeing with the Athlon64
X2 -- I haven't run this particular test yet, but I will run it later
tonight (compiled only -- I run Gentoo so I don't have a pre-compiled
i486 executable to deal with). :)

By the way, what compiler version are you on? I'm on 4.2.0 at the moment
-- nothing newer has escaped Gentoo's QA process yet.