B
Bradley Kite
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 (Apar=
t
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 consid=
ering
it runs twice as slowly as Perl (see below).
I was also interested in comparing the performance of Ruby against somethin=
g
like Perl, and (although this test is VERY simple) thought that I'd benchma=
rk
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 waiti=
ng).
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 =3D 0;
while ($num < 94967295)
{
$num +=3D 1;
}
###############
#!/usr/bin/ruby
num =3D 0
while num < 94967295 do
num +=3D 1
end
###############
int main()
{
int counter =3D 0;
while (counter < 94967295)
{
counter +=3D 1;
}
}
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 (Apar=
t
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 consid=
ering
it runs twice as slowly as Perl (see below).
I was also interested in comparing the performance of Ruby against somethin=
g
like Perl, and (although this test is VERY simple) thought that I'd benchma=
rk
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 waiti=
ng).
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 =3D 0;
while ($num < 94967295)
{
$num +=3D 1;
}
###############
#!/usr/bin/ruby
num =3D 0
while num < 94967295 do
num +=3D 1
end
###############
int main()
{
int counter =3D 0;
while (counter < 94967295)
{
counter +=3D 1;
}
}