Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-08-02 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (54 votes), past polls