Math::Random::MT versus embedded function rand()
5.010001
Math::Random::MT: 1.10
Rate mt rand()
mt 714566/s -- -96%
rand() 19268703/s 2597% --
use strict;
use warnings;
use Benchmark ':all';
use Math::Random::MT;
my $mt = Math::Random::MT->new(time);
srand(time);
print "$]\n";
print "Math::Random::MT: $Math::Random::MT::VERSION\n";
cmpthese(
-1 => {
'rand()' => sub { rand() },
'mt' => sub { $mt->rand() },
}
);
まあ妥当かな、という印象。
なお、このベンチは本当です。
Published: 2010-04-03(Sat) 05:06