How fast does your Ruby run?

On Sat, 22 Sep 2007, Rick DeNatale wrote:

sources): 3.561564

One more strike against using Debian packaged Ruby!

If I infer correctly it’s rather one more strike against compiling with
the “–enable-pthread” switch. So while it’s yet another oportunity of
Debian bashing I guess the more clever option would be to ask why
“–enable-pthread” sucks so bad and whether Ubuntu (note that
possibly Debian uses it too, I don’t know) should switch it off…
*t

Tomas P.'s Mailing L. wrote:

If I infer correctly it’s rather one more strike against compiling with
the “–enable-pthread” switch. So while it’s yet another oportunity of
Debian bashing I guess the more clever option would be to ask why
“–enable-pthread” sucks so bad and whether Ubuntu (note that
possibly Debian uses it too, I don’t know) should switch it off…

The --enable-pthread might be for compatibility with the tcl/tk package
(IIRC correctly, they should either both use it or both not use it).

Intel Dual core 3.2 GHz, Win XP machine

Ruby 1.8.6 patch 0
It took 14.344 seconds to run. 69715 iterations per second.

I am SO embarrassed.

On Sun, 23 Sep 2007, Rick DeNatale wrote:

I’m not bashing Debian in general, just the Debian approach to Ruby packaging.

In general I’m quite happy with Debian/Ubuntu, but not with deb packaged Ruby.

Shall I bite?

So what’s wrong with Debian’s Ruby packaging and what would be the
proper
way? (AFAIcan see the above problem doesn’t have anything to do with
Debian’s packaging but instead with a compile flag?)
*t

Tomas P.'s Mailing L. wrote:

On Sun, 23 Sep 2007, Rick DeNatale wrote:

So what’s wrong with Debian’s Ruby packaging and what would be the
proper
way? (AFAIcan see the above problem doesn’t have anything to do with
Debian’s packaging but instead with a compile flag?)
*t

Probably it depends on architecture of the binary-package which was
prepared for.
it’s too “universal”. for example binary packages are made por i386 ,
not for i686.

On 9/22/07, Tomas P.'s Mailing L. [email protected] wrote:

On Sat, 22 Sep 2007, Rick DeNatale wrote:

One more strike against using Debian packaged Ruby!

If I infer correctly it’s rather one more strike against compiling with
the “–enable-pthread” switch. So while it’s yet another oportunity of
Debian bashing I guess the more clever option would be to ask why
“–enable-pthread” sucks so bad and whether Ubuntu (note that
possibly Debian uses it too, I don’t know) should switch it off…

I’m not bashing Debian in general, just the Debian approach to Ruby
packaging.

In general I’m quite happy with Debian/Ubuntu, but not with deb packaged
Ruby.


Rick DeNatale

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

SpringFlowers AutumnMoon 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:


C:> ruby calculate.rb
55

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


n = 1_000_000

start_time = Time.now

for i in 1…n
t = (1…10).inject {|x, y| x + y }
end

finish_time = Time.now

p t

puts
print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ",
RUBY_PLATFORM

puts
print “It took #{finish_time - start_time} seconds to run.”
print " #{(n / (finish_time - start_time)).to_i} iterations per
second.\n"

Intel® Core™2 Duo CPU T7500 @ 2.20GHz 800MHz FSB
Ubuntu 7.04

Ruby1.8.5 on i486-Linux
It took 17316402 seconds to run. 58261 iterations per second.

Ruby1.9.0 on i686-Linux
It took 2.24857 seconds to run. 4447227 iterations per second.

Hi,

How fast does your Ruby run?

Ruby 1.8.5 patch 12 on powerpc-darwin8.8.0
It took 38.723017 seconds to run. 25824 iterations per
second.

PowerPC G4, 1.42 GHz :wink:

Julian

SpringFlowers AutumnMoon 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:


C:> ruby calculate.rb
55

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


n = 1_000_000

start_time = Time.now

for i in 1…n
t = (1…10).inject {|x, y| x + y }
end

finish_time = Time.now

p t

puts
print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ",
RUBY_PLATFORM

puts
print “It took #{finish_time - start_time} seconds to run.”
print " #{(n / (finish_time - start_time)).to_i} iterations per
second.\n"

55

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

this is on a 3.2Ghz with HT, VISTA, guess vista is slower than XP

On Mon, Sep 24, 2007 at 01:59:29AM +0900, Michael G. wrote:

Intel® Core™2 Duo CPU T7500 @ 2.20GHz 800MHz FSB
Ubuntu 7.04

Ruby1.8.5 on i486-Linux
It took 17316402 seconds to run. 58261 iterations per second.

Is that missing a decimal point after the 17?

SpringFlowers AutumnMoon 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:


C:> ruby calculate.rb
55

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

Gotta love the Mac:

55

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

Not as fast and Todd’s but still a screamer… :wink:

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.

I downloaded the Ruby 1.9 from

Ruby 1.9.0 Binary (md5: 9809f6e9bc7795f83612b369e36c8724) Developer
version (experimental)

in Download Ruby

for the Win XP version.

In article [email protected],
SpringFlowers AutumnMoon [email protected] wrote:

in Download Ruby

for the Win XP version.

I’m not a big fan of compiling and installing bleeding-edge code…
I’ll wait for final releases on my system… :wink:

On Sun, 23 Sep 2007, xx xx wrote:

it’s too “universal”. for example binary packages are made por i386 ,
not for i686.

However the data I have available indicate that compiling ruby for i486
(afaik Debian compiles for i486 and not i386) instead of against i686
doesn’t matter much:

On Sat, 22 Sep 2007, Josip G. wrote:

  1. 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.

Which would make a difference of rougly 4%.

Am I misstaken?

Anything else that sucks so bad with Debian packaging?
*t

On Mon, 24 Sep 2007, Michael G. wrote:

t = (1…10).inject {|x, y| x + y }
puts
Ruby1.9.0 on i686-Linux
It took 2.24857 seconds to run. 4447227 iterations per second.

Are you certain?!?!? That would be a 100 fold improvement?!!?!?!
?!?!
*t

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.

Followup, with the newly released 1.8.6p100

robert-mcgoverns-computer:~/Documents/Programming robertmcgovern$ ruby
test.rb
55

Ruby 1.8.6 patch 110 on i686-darwin8.10.1
It took 9.955669 seconds to run. 100445 iterations persecond.

Slightly slower, running on battery but I don’t think it makes any
difference.

Rob

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?

On Mon, 24 Sep 2007 06:40, Tomas P.'s Mailing L. wrote:

It took 2.24857 seconds to run. 4447227 iterations per second.

Are you certain?!?!? That would be a 100 fold improvement?!!?!?!
?!?!
*t

I guess he typed the results instead of copying and pasting, judging
by the missing period after 17 in the first result; so that may be a
typo too.

Anyway, here it goes:

Intel® Pentium® M processor 2.00GHz
Arch Linux

Ruby 1.8.6 patch 36 on i686-linux
It took 16.125842 seconds to run. 62012 iterations per second.

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

about 52,000 iterations per second to 58,000… I wonder why other

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

Lloyd L. 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”.