#!/usr/local/bin/perl -w

use strict;
use lib "/home/martink/export/extern/perl/lib/site_perl/5.005";
use Time::HiRes qw(gettimeofday tv_interval);
use Math::Random;
use Statistics::ChiSquare;
use Math::Random::MT;

$\="\n";
$,=" ";

my $t;
my $N = 1000000;

random_set_seed_from_phrase("asdlkjasdfo2394852");
my $mt = Math::Random::MT->new(time);
$t = [gettimeofday];
my @mtr;
for(0..$N-1) {
  $mtr [ 30 * $mt->rand() ] ++;
}
print int($N/tv_interval($t)),"MT values per second",chisquare(@mtr);

random_set_seed_from_phrase("asdlkjasdfo2394852");
$t = [gettimeofday];
my @rlr;
for(0..$N-1) {
  $rlr[ 30 * random_uniform ] ++;
}
print int($N/tv_interval($t)),"randlib values per second",chisquare(@rlr);

$t = [gettimeofday];
my @rr;
for(0..$N-1) {
  $rr[ 30 * rand ]++;
}
print int($N/tv_interval($t)),"rand() values per second",chisquare(@rr);
