in reply to Re: Is rand() really that slow or am I just using it wrong?
in thread Is rand() really that slow or am I just using it wrong?
Math::Random::MT is over an order of magnitude slower than the default rand function. Far superior, but much slower:
require Math::Random::MT;; cmpthese -1,{a=>q[my $a; $a=rand() for 1..1e6],b=>q[my $a; $a=Math::Ra +ndom::MT::rand() for 1..1e6] };; (warning: too few iterations for a reliable count) s/iter b a b 1.58 -- -93% a 0.105 1407% --
And for picking 1 of 68 for random test data; the built-in is perfectly adequate.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is rand() really that slow or am I just using it wrong?
by mtmcc (Hermit) on Aug 08, 2013 at 23:10 UTC | |
by BrowserUk (Patriarch) on Aug 09, 2013 at 00:03 UTC | |
by bulk88 (Priest) on Aug 10, 2013 at 21:54 UTC | |
by BrowserUk (Patriarch) on Aug 11, 2013 at 05:19 UTC |