Ruby Performance

Bradley Kite wrote:

Those idioms are around 21 seconds each in Ruby.

In perl, its 11 seconds to do this:

for (0..94967295)
{

}

The question is not so much about the run-time of a particular action,
but (in a web-based environment, for example) its more to do with
the number of concurrent users you can have without having to buy
more hardware.

This is much faster in Perl, too:

my $num = 2 ** 65;

my $i = 0;
while ($i < 94967295)
{
    $num += 1;
    $i += 1;
}

From this benchmark alone, you can see, that Perl is superior to Ruby in every thinkable way.

···

--
Florian Frank

So use perl already.

···

On 13/08/2005, at 1:19 AM, Bradley Kite wrote:

Those idioms are around 21 seconds each in Ruby.

In perl, its 11 seconds to do this:

for (0..94967295)
{

}

The question is not so much about the run-time of a particular action,
but (in a web-based environment, for example) its more to do with
the number of concurrent users you can have without having to buy
more hardware.

--
Brad.

On 12/08/05, Robert Klemme <bob.news@gmx.net> wrote:

Bradley Kite wrote:

Hi all,

I'm a relatively new Ruby programmer, I am curious as to what Ruby is
trying to achieve that other scripting languages do not already offer
(Apart from the syntactic differences of yet another scripting
language, that is).
The reason I ask is that it must offer something that is worth a lot
considering it runs twice as slowly as Perl (see below).

I was also interested in comparing the performance of Ruby against
something like Perl, and (although this test is VERY simple) thought
that I'd benchmark
a simple counter in both Ruby and Perl. The number that it counts to
is arbitrary,
I started with 4294967296 and kept reducing it because I got bored of
waiting). Code is provided below.

Any way, on a 3Ghz P4 CPU, I got the following results:

Perl:
real 0m24.569s
user 0m24.499s
sys 0m0.068s

Ruby:
real 0m57.218s
user 0m57.108s
sys 0m0.109s

(Just out of interest I did it in C as well):

(Average Run, non-optimised)
real 0m0.142s
user 0m0.136s
sys 0m0.005s

(Average Run, -O3 optimisations):
real 0m0.074s
user 0m0.070s
sys 0m0.004s

##################################

#!/usr/bin/perl
my $num = 0;

while ($num < 94967295)
{
    $num += 1;
}

###############

#!/usr/bin/ruby
num = 0

while num < 94967295 do
    num += 1
end

###############

int main()
{
    int counter = 0;

    while (counter < 94967295)
    {
        counter += 1;
    }
}

Just out of curiosity: did you also benchmark these Ruby idioms (which I
regard more typical):

94967295.times do
end

for i in 0..94967295 do
end

0.upto 94967295 do
end

Kind regards

   robert

Austin Ziegler wrote:

> Bradley Kite wrote:
> > I was also interested in comparing the performance of Ruby against something
> > like Perl, and (although this test is VERY simple) thought that I'd benchmark
> > a simple counter in both Ruby and Perl.
> That's even more simplistic than the benchmark programs on the Computer
> Language Shootout :slight_smile:
>
> Here's Ruby vs Perl
> http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu
>
> and here are the old Doug Bagley programs
> http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu

And, like Mr Kite's test, none of the Alioth shootout benchmarks are
worth squat.

Others find worth where you fail.

···

On 8/15/05, Isaac Gouy <igouy@yahoo.com> wrote:

-austin
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Compared with - say - slashdot?

···

On 12/08/05, Julian Leviston <julian@coretech.net.au> wrote:

The bottleneck is usually the database, tho... no? :slight_smile:

Read the ruby on rails book - and then you'll get some real-world-
applications... take a look at basecamp - that's running with
THOUSANDS of users... not sure how many concurrent... and it's all of
one to two machines...

Julian.

On 13/08/2005, at 1:19 AM, Bradley Kite wrote:

> Those idioms are around 21 seconds each in Ruby.
>
> In perl, its 11 seconds to do this:
>
> for (0..94967295)
> {
>
> }
>
> The question is not so much about the run-time of a particular action,
> but (in a web-based environment, for example) its more to do with
> the number of concurrent users you can have without having to buy
> more hardware.
>
> --
> Brad.
>
> On 12/08/05, Robert Klemme <bob.news@gmx.net> wrote:
>
>> Bradley Kite wrote:
>>
>>> Hi all,
>>>
>>> I'm a relatively new Ruby programmer, I am curious as to what
>>> Ruby is
>>> trying to achieve that other scripting languages do not already
>>> offer
>>> (Apart from the syntactic differences of yet another scripting
>>> language, that is).
>>> The reason I ask is that it must offer something that is worth a lot
>>> considering it runs twice as slowly as Perl (see below).
>>>
>>> I was also interested in comparing the performance of Ruby against
>>> something like Perl, and (although this test is VERY simple) thought
>>> that I'd benchmark
>>> a simple counter in both Ruby and Perl. The number that it counts to
>>> is arbitrary,
>>> I started with 4294967296 and kept reducing it because I got
>>> bored of
>>> waiting). Code is provided below.
>>>
>>> Any way, on a 3Ghz P4 CPU, I got the following results:
>>>
>>> Perl:
>>> real 0m24.569s
>>> user 0m24.499s
>>> sys 0m0.068s
>>>
>>> Ruby:
>>> real 0m57.218s
>>> user 0m57.108s
>>> sys 0m0.109s
>>>
>>> (Just out of interest I did it in C as well):
>>>
>>> (Average Run, non-optimised)
>>> real 0m0.142s
>>> user 0m0.136s
>>> sys 0m0.005s
>>>
>>> (Average Run, -O3 optimisations):
>>> real 0m0.074s
>>> user 0m0.070s
>>> sys 0m0.004s
>>>
>>> ##################################
>>>
>>> #!/usr/bin/perl
>>> my $num = 0;
>>>
>>> while ($num < 94967295)
>>> {
>>> $num += 1;
>>> }
>>>
>>> ###############
>>>
>>> #!/usr/bin/ruby
>>> num = 0
>>>
>>> while num < 94967295 do
>>> num += 1
>>> end
>>>
>>> ###############
>>>
>>> int main()
>>> {
>>> int counter = 0;
>>>
>>> while (counter < 94967295)
>>> {
>>> counter += 1;
>>> }
>>> }
>>>
>>
>> Just out of curiosity: did you also benchmark these Ruby idioms
>> (which I
>> regard more typical):
>>
>> 94967295.times do
>> end
>>
>> for i in 0..94967295 do
>> end
>>
>> 0.upto 94967295 do
>> end
>>
>> Kind regards
>>
>> robert
>>
>
>

TIMTOWTDI - there is more than one way to do it

···

On 8/12/05, Brock Weaver <brockweaver@gmail.com> wrote:

I'm not much of a Perl guy, so I don't know what TIMTOWTDI stands for.

This Is My T... O... Way To Do It?

Help a brother out :slight_smile:

Also, somebody mentioned slashdot -- does this mean we should bring up Nazis
too so we can kill the thread?

I'm sorry, I'm a little caffiened up today.

I do have a valid comment though: I was running ruby from a USB stick, and
it was horribly slow (2-3 minutes to run "ruby -v"). Installing onto my 2nd
logical partition (D:) helped, but it was still about 30 seconds to do the
same version check. Installing onto C: -- same physical drive as D: -- made
"ruby -v" practically instantaneous.

Unfortunately, yes I have Windows, so I'm sure that makes a difference.

On 8/12/05, Adrian Howard <adrianh@quietstars.com> wrote:
>
> On 12 Aug 2005, at 16:23, Lothar Scholz wrote:
> [snip]
> > Perl <-> Ruby:
> > Perl is so ugly and difficult i don't want to compare it with ruby.
> > I doubt that it is possible to develop huge Perl programs where you
> > have a changing team of different programmers working on the same
> > code.
> [snip]
>
> As somebody who does this on a regular basis I'd have to disagree :slight_smile:
>
> Adrian
>
>
>

--
Brock Weaver
http://www.circaware.com

[snip]

Maybe your collegues are maybe better motivated, better paid and
better educated, then the onces i had to work with in the past
(on a very small project - in terms of LOC not of importance for the company).

[snip]

I'd say a group of poorly motivated, poorly paid and badly educated developers working on a project of no importance to the company is doomed whatever language they're working in :slight_smile:

Adrian

···

On 12 Aug 2005, at 17:38, Lothar Scholz wrote:

Brock Weaver wrote:

This Is My T... O... Way To Do It?

There Is More Than One Way To Do It.

What are the specs of the Windows box you have if it takes 30 seconds
to run 'ruby -v'???

Adrian Howard ha scritto:

[snip]

> - Perl 6 now! Many useful things that Perl 5 lacks and that Perl
> 6 will give you like a decent built in OO system, classes as proper
> objects, coroutines, simple block passing, etc. Ruby does now.

Yes thats also going to piss me off. I thought they got a few paid
full time worker on the language (at least one or two from
activestate). But i see almost no progress in Perl 6.

I do. Parrot is an interesting platform for dynamic languages that's just getting to a reasonable state, and Pugs is just /storming/ along. You can play with large chunks of Perl 6 now.

first, let me state that I do have great hopes for parrot, I think perl6 has some very interesting things[1] and pugs is massively cool.

But I think Lothar is right: IMVHO perl6 could have been definitely more simple, withouth needing ~150 operators[2], special variables like $?CLASS, ::?CLASS or ::*::Main[3], differentiating multi/method/sub etc

[1] to be fair, I do love multimethods and rules. Real love.
[2] http://www.ozonehouse.com/mark/blog/code/PeriodicTable.pdf
[3] http://svn.openfoundry.org/pugs/docs/quickref/namespace

···

On 12 Aug 2005, at 17:36, Lothar Scholz wrote:

Mary Poppins said:

From this benchmark alone, you can see, that Perl is superior to Ruby
in every thinkable way.

Now I want to see you do the chimney sweep dance! Dance! Dance!

Florian Frank wrote:

This is much faster in Perl, too:

my $num = 2 ** 65;

my $i = 0;
while ($i < 94967295)
{
    $num += 1;
    $i += 1;
}

From this benchmark alone, you can see, that Perl is superior to Ruby
in every thinkable way.

Amazing how you extract "every thinkable way" from an eight liner. Wow!

    robert

That's only because they're uninformed or blinkered by the false
presentation on the shootout.

-austin

···

On 8/15/05, Isaac Gouy <igouy@yahoo.com> wrote:

Austin Ziegler wrote:
> On 8/15/05, Isaac Gouy <igouy@yahoo.com> wrote:
> > Bradley Kite wrote:
> > > I was also interested in comparing the performance of Ruby against something
> > > like Perl, and (although this test is VERY simple) thought that I'd benchmark
> > > a simple counter in both Ruby and Perl.
> > That's even more simplistic than the benchmark programs on the Computer
> > Language Shootout :slight_smile:
> >
> > Here's Ruby vs Perl
> > http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu
> >
> > and here are the old Doug Bagley programs
> > http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu
>
> And, like Mr Kite's test, none of the Alioth shootout benchmarks are
> worth squat.
Others find worth where you fail.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

[snip]

I'm sure with sufficient effort somebody could run Amazon with a large parallel group of highly trained stoats. Who cares :slight_smile:

There are large web sites built with Java, Perl, Ruby, C++, Lisp, C#, PHP and god knows how many other languages. PHP and Perl didn't build their market share because they were /faster/ - they built it because they were /better/ (for certain definitions of "better").

Perl's big advantage is that it's a nice flexible language that enable you to build applications quickly and reliably (despite what some people say :slight_smile:

Ruby's advantage over Perl 5 is that it does some stuff that Perl 5 can't do, and makes much of the stuff it can do easier (in certain areas anyway).

Compare the simplicity of overriding some_method= with messing with lvalue subs and tied variables to get the same affect in Perl 5. Some things are simpler and, when it comes to writing and maintaining code, simpler is better.

Adrian

···

On 12 Aug 2005, at 16:39, Bradley Kite wrote:

Compared with - say - slashdot?

i dunno - works for us :wink:

-a

···

On Sat, 13 Aug 2005, Adrian Howard wrote:

On 12 Aug 2005, at 17:38, Lothar Scholz wrote:
[snip]

Maybe your collegues are maybe better motivated, better paid and
better educated, then the onces i had to work with in the past
(on a very small project - in terms of LOC not of importance for the company).

[snip]

I'd say a group of poorly motivated, poorly paid and badly educated developers working on a project of no importance to the company is doomed whatever language they're working in :slight_smile:

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

Performance is a consideration, but it is only one of many. I switched to
Ruby because of tangible reasons -- for web work I could do it under Ruby and
the framework of my choice faster than I could with anything I had experience
in Perl 3 years ago -- and also for intangibles -- as a long time Perl user
at that time, I found Ruby's syntax to be tremendously more enjoyable to work
with than Perl 5's.

But performance is still a factor. I originally had some concern that Ruby
seemed to be slower than Perl. However, as many people have said,
performance only becomes important when it becomes a problem, and it just
isn't a problem with Ruby, for me.

Web benchmarks are notoriously hard, as they are extremely context sensitive.
How much data is being pushed? How much of it is dynamic? What sort of
manipulations have to be done, and how much database interaction must occur?
The answers to these and other questions all affect the results. However, I
have a web app in production right now, written in Ruby, running on a single
processor midrange linux server (no 3.4Ghz P4's here), with a database
backend, being used by a Fortune 500 company. The design spec called for it
to be able to handle 30 requests per second.

In real world usage they have not come anywhere close to that yet, so time
will tell what happens when there is real data in it, but in testing with
current versions of the framework, I am getting as many as 285 requests per
second for a typical 9k HTML page, served through https, with some modest
dynamic content, when feeding it as many requests as I can (.0035 seconds or
less per page).

In real usage, with larger amounts of user data causing long pages with more
dynamic content, this will go down, but I estimate that it will still average
80-100 requests per second, and I did nothing in particular to enhance
performance. In fact, I coded some sections in ways that improved
readability and maintainability at the cost of performance.

Ruby is plenty fast.

Kirk Haines

···

On Friday 12 August 2005 9:39 am, Bradley Kite wrote:

Compared with - say - slashdot?

On 12/08/05, Julian Leviston <julian@coretech.net.au> wrote:
> The bottleneck is usually the database, tho... no? :slight_smile:
>
> Read the ruby on rails book - and then you'll get some real-world-
> applications... take a look at basecamp - that's running with
> THOUSANDS of users... not sure how many concurrent... and it's all of
> one to two machines...

GED/J d-- s:++>: a-- C++(++++) ULU++ P+ L++ E---- W+(-) N+++ o+ K+++ w---
O- M+ V-- PS++>$ PE++>$ Y++ PGP++ t- 5+++ X++ R+++>$ tv+ b+ DI+++ D+++
G+++++ e++ h r-- y++**

lol!

···

On 8/13/05, luke dot <l.d.u.n.c.a.l.f.e@e.m.lc.c> wrote:

Mary Poppins said:

> From this benchmark alone, you can see, that Perl is superior to Ruby
> in every thinkable way.

Now I want to see you do the chimney sweep dance! Dance! Dance!

first, let me state that I do have great hopes for parrot,

i hope parrot dies on the vine...but it doesn't look like it's going to

I think perl6 has some very interesting things[1]

it's too bad larry wall caved to the python people. is perl5 ugly? you
betcha :slight_smile: i like everything about perl, tim toadie, perl magic, line noise

most of the perl code i write on windows is technically perl4, and i
can use a 345k dos executable to run/distribute it. very quick
execution. i have the latest perl5 installed but most of the quick and
dirty stuff i write is 4

···

gabriele renzi wrote on 8/12/2005 6:26 PM:

--
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org

It seems I saw some irony somewhere ...

···

On 15/08/05, Robert Klemme <bob.news@gmx.net> wrote:

Florian Frank wrote:
> This is much faster in Perl, too:
>
> my $num = 2 ** 65;
>
> my $i = 0;
> while ($i < 94967295)
> {
> $num += 1;
> $i += 1;
> }
>
> From this benchmark alone, you can see, that Perl is superior to Ruby
> in every thinkable way.

Amazing how you extract "every thinkable way" from an eight liner. Wow!

    robert

And there we have it, irrefutable proof that sarcasm often ends up on the bit bucket in internet communication.

:wink:

Julian.

···

On 15/08/2005, at 6:01 PM, Robert Klemme wrote:

Florian Frank wrote:

This is much faster in Perl, too:

my $num = 2 ** 65;

my $i = 0;
while ($i < 94967295)
{
    $num += 1;
    $i += 1;
}

From this benchmark alone, you can see, that Perl is superior to Ruby
in every thinkable way.

Amazing how you extract "every thinkable way" from an eight liner. Wow!

    robert

[snip]

But I think Lothar is right: IMVHO perl6 could have been definitely more simple, withouth needing ~150 operators[2]

Curiously enough this number isn't radically more than there are in Perl 5 (128) - and they're more logically grouped and named now.

, special variables like $?CLASS, ::?CLASS or ::*::Main[3], differentiating multi/method/sub etc

I'm reserving judgement. I've not had the spare time to keep really up to date and play with Perl 6 properly. However, my suspicion is that it's going to be a lot simpler and logical than many people expect.

Adriian

···

On 12 Aug 2005, at 23:26, gabriele renzi wrote:

Austin Ziegler wrote:

> Austin Ziegler wrote:
> > > Bradley Kite wrote:
> > > > I was also interested in comparing the performance of Ruby against something
> > > > like Perl, and (although this test is VERY simple) thought that I'd benchmark
> > > > a simple counter in both Ruby and Perl.
> > > That's even more simplistic than the benchmark programs on the Computer
> > > Language Shootout :slight_smile:
> > >
> > > Here's Ruby vs Perl
> > > http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu
> > >
> > > and here are the old Doug Bagley programs
> > > http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu
> >
> > And, like Mr Kite's test, none of the Alioth shootout benchmarks are
> > worth squat.
> Others find worth where you fail.

That's only because they're uninformed or blinkered by the false
presentation on the shootout.

"false presentation" - another baseless accusation?

What specifically is false about the presentation?

···

On 8/15/05, Isaac Gouy <igouy@yahoo.com> wrote:
> > On 8/15/05, Isaac Gouy <igouy@yahoo.com> wrote:

-austin
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca