Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: The Great Computer Language Shootout

by Your Mother (Canon)
on Sep 22, 2004 at 07:05 UTC ( #392857=note: print w/ replies, xml ) Need Help??

in reply to The Great Computer Language Shootout

Others could poke better holes but here's my stab, assuming I'm using Benchmark correctly which I'm never sure about. Their random number generator perl versus perl's vanilla rand(). Off by between 200% and 1,500%.

use Benchmark qw(cmpthese); use strict; my $theirs = q# use constant IM => 139968; use constant IA => 3877; use constant IC => 29573; my $LAST = 42; sub gen_random { ($_[0] * ($LAST = ($LAST * IA + IC) % IM)) / IM } my $N = ($ARGV[0] || 100) - 1; gen_random(100.0) while ($N--); sprintf "%.9f\n", gen_random(100.0); #; my $native = q{rand(100) for 1 .. 100}; cmpthese(1_000_000, { theirs => $theirs, native => $native, }); __END__ Rate theirs native theirs 4414/s -- -68% native 13961/s 216% --

And if you turn it down to their default of a single run/generation:

Rate theirs native theirs 121507/s -- -93% native 1851852/s 1424% --

(Update: I know they're doing "the same algorithm" for each; just seems wrong to feed a cat dog food.)

Comment on Re: The Great Computer Language Shootout
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://392857]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2014-09-30 17:03 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (378 votes), past polls