develooper Front page | perl.fwp | Postings from November 2001

Feel good benchmarks

Thread Next
Michael G Schwern
November 20, 2001 02:39
Feel good benchmarks
Message ID:
Some of you may get depressed thinking about all this bloat we've put
into the language to drag it down.

Well, I've developed a truely rigorous benchmark designed to show how
far Perl has come:

    sub f {
        my($num) = shift;
        return $num if $num <= 1;
        return f($num-1) + f($num-2);

    print f(25);

real    0m2.282s
user    0m2.210s
sys     0m0.010s

Debian's 5.6.1
real    0m2.643s
user    0m2.510s
sys     0m0.020s

My own compiled 5.6.1
real    0m2.141s
user    0m2.080s
sys     0m0.020s

real    0m2.180s
user    0m2.140s
sys     0m0.010s

real    0m2.342s
user    0m2.140s
sys     0m0.160s

real    0m5.515s
user    0m5.380s
sys     0m0.110s

real    0m5.542s
user    0m5.340s
sys     0m0.150s

real    0m5.581s
user    0m5.340s
sys     0m0.200s

So we're doing something right.  And this lame benchmark might
actually be useful in convincing some luddite 5.004_04 user to upgrade

And for comparative purposes

    def f(num)
        return num if num <= 1
        return f(num-1) + f(num-2)

    print f(25)

Ruby 1.6.5
real    0m2.225s
user    0m2.190s
sys     0m0.000s

Oh dear.  And it took one less line, too.

And just to end this feel good email on a real downer:

    #include <stdio.h>

    int f (int num) {
        if( num <= 1 ) 
            return num;
        return f(num-1) + f(num-2);

    int main (void) {
        printf("%d", f(25));

gcc 2.95.4
real    0m0.077s
user    0m0.030s
sys     0m0.000s


Michael G. Schwern   <>
Perl Quality Assurance	    <>	       Kwalitee Is Job One
OH GOD!!  It's LINUX!  All you Linux fanboys go wild!  It never crashes!
It'll wash your underpants!  It'll eat your dog for you, if you want your
dog to be eaten!  It'll make you attractive and smell good and... it'll...
uh... uh.  Man, I'm so sick of this shit.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About