Il giorno ven, 12/08/2005 alle 23.27 +0900, Bradley Kite ha scritto: > 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 > I think the performance issues will be fixed with the new virtual machine they are developing, just look at this: $ time ruby1.8 perf.rb real 0m57.328s user 0m52.766s sys 0m0.178s $ time ruby1.9 perf.rb real 0m41.883s user 0m40.081s sys 0m0.085s $ time ruby1.9 -rite perf.rb real 0m2.528s user 0m2.351s sys 0m0.010s ruby1.9 -rite means run ruby with the new VM, Regards, Paolo. > (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; > } > } >