From: Bradley Kite Date: 2005-08-13T00:39:01+09:00 Subject: Re: Ruby Performance Compared with - say - slashdot? On 12/08/05, Julian Leviston wrote: > The bottleneck is usually the database, tho... no? :-) > > 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 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 > >> > > > > > > >