J
Jaypee
Hello,
I am not a performance freak at all but I've noticed that despite a huge
difference between a single CPU 1GHz G4 and a dual 2 GHz G5, both
running ruby 1.8.2 with 1GB of RAM on Mac OS X 10.3.8, there was only a
33% difference in the calculation of a factorial:
I used the following code:
#!/usr/local/bin/ruby
class Integer
def factorial
(1..self).inject(1) { |f, n| f * n }
end
end
puts 100000.factorial
It takes about 9 minutes on the lower profile machine and 6 min or so on
the bigger one.
Generally, the generation of processor (G4 vs. G5) alone is responsible
of a similar difference at equal clock frequencies. But here, I expected
a bigger difference given the combined effect of a higher clock, a
higher generation and a dual CPU.
BTW, I was not able to make a comparable test on my 2.6 GHz 1GB Windows
XP SP2 workstation which failed at 9273.factorial. I don' t remember the
message but it's easy to reproduce.
Is this kind of performance "normal" given the algorithm used or is
there a balance between the coding style and the performances that could
be wise to consider?
I have no performance objective, I am just curious.
Thank you for your advices,
Jean-Pierre
I am not a performance freak at all but I've noticed that despite a huge
difference between a single CPU 1GHz G4 and a dual 2 GHz G5, both
running ruby 1.8.2 with 1GB of RAM on Mac OS X 10.3.8, there was only a
33% difference in the calculation of a factorial:
I used the following code:
#!/usr/local/bin/ruby
class Integer
def factorial
(1..self).inject(1) { |f, n| f * n }
end
end
puts 100000.factorial
It takes about 9 minutes on the lower profile machine and 6 min or so on
the bigger one.
Generally, the generation of processor (G4 vs. G5) alone is responsible
of a similar difference at equal clock frequencies. But here, I expected
a bigger difference given the combined effect of a higher clock, a
higher generation and a dual CPU.
BTW, I was not able to make a comparable test on my 2.6 GHz 1GB Windows
XP SP2 workstation which failed at 9273.factorial. I don' t remember the
message but it's easy to reproduce.
Is this kind of performance "normal" given the algorithm used or is
there a balance between the coding style and the performances that could
be wise to consider?
I have no performance objective, I am just curious.
Thank you for your advices,
Jean-Pierre