How fast does your Ruby run?

Hi all,

Ok, here’s some more numbers (comparing ubuntu pre-compiled, compiled
from sources and development version):

  • Ruby 1.8.5 shipped with Ubuntu: 30.871182 seconds
  • Ruby 1.8.5 compiled from sources: 12.173341 seconds (wooh, what a
    difference!)
  • Ruby 1.8.6 compiled from sources: 11.238127
  • Ruby 1.9.0 (downloaded today from ruby-lang.org and compiled from
    sources): 3.561564

All the tests have been run on an Intel(R) Pentium(R) D CPU 2.80GHz
running Kubuntu Linux 7.04 (Feisty Fawn).

See ya!

Intel Dual Core 2GHz, 2GB RAM:

As posted:

ruby calculate.rb
55

Ruby 1.8.6 patch 0 on i386-mswin32
It took 15.235 seconds to run. 65638 iterations per
second.

with x,y = nil

ruby calculate.rb
55

Ruby 1.8.6 patch 0 on i386-mswin32
It took 13.656 seconds to run. 73227 iterations per
second.

Don’t have 1.9 installed, I should definitely give that a try.

Jason

2007/9/21, Jaime I. [email protected]:

2007/9/21, SpringFlowers AutumnMoon [email protected]:

How fast does your Ruby run?

After submitting the results for my local machines, I thought it would
be a good idea to test some servers I work with. Here it goes:

*** Dreamhost shared hosting

$ ruby calculate.rb
55

Ruby 1.8.5 on i386-linux
It took 36.407013 seconds to run. 27467 iterations per
second.

*** Textdrive shared hosting

$ ruby calculate.rb
55

Ruby 1.8.4 on i386-freebsd5
It took 22.436537 seconds to run. 44570 iterations per
second.

Le 21 septembre à 12:14, F. Senault a écrit :

  • PIII 500MHz (diskless workstation with very limited RAM - especially
    raised from the dead just for you, people !) :

Ruby 1.8.4 patch ? on i386-freebsd6
It took 202.375195 seconds to run. 4941 iterations per second.

Forgot one :

  • Intel Celeron 633MHz (short on RAM too) :

Ruby 1.8.6 patch 0 on i386-freebsd5
It took 105.835886 seconds to run. 9448 iterations per second.

(And that one is an important production machine, nothing less !)

Fred

Josip G. wrote:

  1. With ruby 1.8.6 compiled from sources on the machine:

    Ruby 1.8.6 on i686-linux
    It took 7.107875 seconds to run. 140689 iterations per
    second.

Obviously, the target instruction set matters quite a lot. I think I’ll
be compiling my own ruby from now on. :slight_smile:

Make sure you use the appropriate “march=” flag when you do. See
http://www.jhaampe.org/software/ruby-gcc for the details.

On Sep 20, 4:49 pm, SpringFlowers AutumnMoon
[email protected] wrote:

How fast does your Ruby run?

I got 53648 iterations per second running the following program,
on an Intel 3.2 GHz HT, Win XP machine:

3GHz Intel P4, HT

Ruby 1.8.5 on i386-mswin32
It took 30.141 seconds to run. 33177 iterations per
second.

Ruby 1.8.6 on i386-mswin32
It took 22.422 seconds to run. 44599 iterations per
second.

On Sep 20, 4:49 pm, SpringFlowers AutumnMoon
[email protected] wrote:

How fast does your Ruby run?

MacBook Pro 2.16 GHz

Ruby 1.8.6 patch 0 on i686-darwin8.9.1
It took 9.167413 seconds to run. 109082 iterations per
second.

Ruby 1.9.0 patch 0 on i686-darwin8.10.1
It took 3.059674 seconds to run. 326832 iterations per
second.

Seeing other 1.9 speeds got me to install it.

Chris

Quoth F. Senault:

  • Intel Celeron 633MHz (short on RAM too) :
    You dreamed of a big star, he played a mean guitar.
    (Pink Floyd, Welcome to the Machine)

Pentium 133MHz w/ 128MiB of ram (my router) running ruby from FC6
updates:

Ruby 1.8.5 patch 52 on i386-linux
It took 2644.671185 seconds to run. 378 iterations per second.

On Sat, 22 Sep 2007, Brian A. wrote:

That’s amazing. Are you sure the only difference was pre-built Ruby
vs. built-from-source? That just seems like too big of a difference.

I was also amyazed. The original poster could actually find out quite
easily whether the improvement comes from recompiling:

apt-get build-dep ruby1.8

apt-get source ruby1.8

cd ruby1.8*

dpkg-buildpackage -rfakeroot

This will build a package that’s not optimized for the local
architecture. In order to do the latter he will need to change the
config/compile options in debian/rules.
*t

On Sep 21, 6:57 am, “Imobach González Sosa” [email protected]
wrote:

Hi all,

Ok, here’s some more numbers (comparing ubuntu pre-compiled, compiled
from sources and development version):

  • Ruby 1.8.5 shipped with Ubuntu: 30.871182 seconds
  • Ruby 1.8.5 compiled from sources: 12.173341 seconds (wooh, what a difference!)

That’s amazing. Are you sure the only difference was pre-built Ruby
vs. built-from-source? That just seems like too big of a difference.

On 9/21/07, SpringFlowers AutumnMoon [email protected] wrote:

How fast does your Ruby run?

Hand built 1.8.6 on 2ghz MacBook, 1gig ram:

RubyMate r6354 running Ruby r1.8.6 (/usr/local/bin/ruby)

test.rb

55

Ruby 1.8.6 patch 0 on i686-darwin8.10.1
It took 9.495808 seconds to run. 105309 iterations persecond.

On 9/21/07, SpringFlowers AutumnMoon [email protected] wrote:

How fast does your Ruby run?

I got 53648 iterations per second running the following program,

P-III 700MHz, 384 megs of ram

55

It took 0.122343 seconds to run. 8173741 iterations per second.

It’s a C version though ducks

xx xx wrote:

hello !

My hardware:
Laptop Asus A6TC - Debian Sid i386
AMD Thurion64x2

uname -a:
Linux adom 2.6.22.5 #1 SMP Wed Aug 29 01:16:06 CEST 2007 i686 GNU/Linux


tests:

Sorry for “269313 iterations” in my previous post - i couldn’t edit it

btw. what is a "version though ducks " ?

hello !

My hardware:
Laptop Asus A6TC - Debian Sid i386
AMD Thurion64x2

uname -a:
Linux adom 2.6.22.5 #1 SMP Wed Aug 29 01:16:06 CEST 2007 i686 GNU/Linux


tests:

  1. ruby compiled by :

apt-get build-dep ruby1.9

apt-get source ruby1.9

Ruby 1.9.0 patch 0 on i686-linux
It took 9.170000 seconds to run. 269313 iterations per
second.

  1. ruby from source (cvs) !!!
    Ruby 1.9.0 patch 0 on i686-linux
    It took 3.713144 seconds to run. 269313 iterations per
    second.

  2. ruby from repository (without optimalization)
    Ruby 1.9.0 patch 0 on i686-linux
    It took 9.500020 seconds to run. 269313 iterations per
    second.

  3. ruby from repository
    Ruby 1.8.6 patch 0 on i686-linux
    It took 25.030340 seconds to run. 269313 iterations per
    second.

Summary: Do I need to try gentoo ? :wink:

On Sep 21, 2007, at 02:20, Josip G. wrote:

Ruby 1.8.5 on i486-linux
3. With ruby 1.8.6 compiled from sources on the machine:

Ruby 1.8.6 on i686-linux
It took 7.107875 seconds to run. 140689 iterations per
second.

Obviously, the target instruction set matters quite a lot. I think
I’ll be compiling my own ruby from now on. :slight_smile:

How can you draw that conclusion? You used three different versions
of ruby.

Todd B. wrote:

a Windows system, though. I haven’t tried the 1.9 installer yet,
either.

Todd
I’ve built using cygwin several times w/out issue. Not recently though,
the setup version has been kept pretty up to date and has been speedy
enough for what I use it for. ( results are posted earlier in the thread
)

On 9/21/07, xx xx [email protected] wrote:


tests:

Sorry for “269313 iterations” in my previous post - i couldn’t edit it

btw. what is a "version though ducks " ?

lol. I imagine he doesn’t want to get swatted by ruby purists. He
compiled into machine code instead of using the interpreter?

For what it’s worth, I was able to have an 800MHz machine do 30
seconds with the 1.8.6 standard build from source by disabling the GC
in irb and loading via…

irb> load “test.rb”

Standard time during normal computer operation for executing the OP’s
code was around 49+/-5 seconds. Normal operation included having a
heavy use network session mixed with X Windows open and a window
manager.

I pushed it to do less than 20 seconds by rewriting the code
(cheating) to omit the inject method, making it look ugly with while
loops, and also leaving out the puts/p/print methods.

I will confirm that it was extremely easy to beat the one-click
install on a newer/faster Windows machine with 1.8.6. Nothing against
that, though, because making a clean install of anything on Windows is
nothing less than an act of God (nothing against the Windows fans
either; it justs seems harder than it needs to be; I think this will
change eventually). I have yet to attempt Cygwin or MingW building on
a Windows system, though. I haven’t tried the 1.9 installer yet,
either.

Todd

Eric H. wrote:

How can you draw that conclusion? You used three different versions of
ruby.

You are right, that was one hasty conclusion.

Here are the real results, indicating how ruby was compiled:

  1. CFLAGS="-O3 -mcpu=i686 -march=i686 -mtune=i686" ./configure
    –target=i686-linux

    Ruby 1.8.5 on i686-linux
    It took 6.561333 seconds to run. 152408 iterations per
    second.

  2. CFLAGS="-O3 -mcpu=i486 -march=i486 -mtune=i486" ./configure
    –target=i486-linux

    Ruby 1.8.5 on i486-linux
    It took 6.847393 seconds to run. 146040 iterations per
    second.

  3. CFLAGS="-O3 -mcpu=i686 -march=i686 -mtune=i686" ./configure
    –target=i686-linux --enable-pthread

    Ruby 1.8.5 on i686-linux
    It took 17.856484 seconds to run. 56002 iterations per
    second.

Note the “–enable-pthread” in the last measurement. The binary
distributed with Ubuntu is compiled with pthreads.

Josip G. wrote:

I’ll be compiling my own ruby from now on. :slight_smile:

second.
Note the “–enable-pthread” in the last measurement. The binary
distributed with Ubuntu is compiled with pthreads.

Oh, and finally, the latest Ruby from svn…

  1. CFLAGS="-O3 -mcpu=i686 -march=i686 -mtune=i686" ./configure
    –enable-pthread

    Ruby 1.9.0 on i686-linux
    It took 2.507824 seconds to run. 398752 iterations per
    second.

On 9/21/07, Imobach González Sosa [email protected] wrote:

Hi all,

Ok, here’s some more numbers (comparing ubuntu pre-compiled, compiled
from sources and development version):

  • Ruby 1.8.5 shipped with Ubuntu: 30.871182 seconds
  • Ruby 1.8.5 compiled from sources: 12.173341 seconds (wooh, what a difference!)
  • Ruby 1.8.6 compiled from sources: 11.238127
  • Ruby 1.9.0 (downloaded today from ruby-lang.org and compiled from
    sources): 3.561564

One more strike against using Debian packaged Ruby!

Just for fun, this is for a Macbook 2.16 GHz Intel Core 2 Duo with 1GB
or ram (Ruby was installed using macports)

55

Ruby 1.8.6 patch 0 on i686-darwin8.10.2
It took 8.688359 seconds to run. 115096 iterations per
second.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/