From: Felix Windt Date: 2007-09-24T11:05:05+09:00 Subject: Re: How fast does your Ruby run? ------=_NextPart_000_00E6_01C7FE14.05B22330 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > -----Original Message----- > From: M. Edward (Ed) Borasky [mailto:znmeb@cesmail.net] > Sent: Sunday, September 23, 2007 6:50 PM > To: ruby-talk ML > Subject: Re: How fast does your Ruby run? > > 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=", where > >> 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/software/ruby-gcc 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. Vanilla Ubuntu, which is still tracking the 4.1 branch: ~$ gcc -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4) I'm curious whether 4.2 would give further performance enhancements - maybe if I have some time this week I'll build a tool chain to test with. Felix ------=_NextPart_000_00E6_01C7FE14.05B22330 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-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