-----BEGIN PGP SIGNED MESSAGE-----
Moin,
On 20-Mar-02 Green, Paul tried to scribble about:
Blasting through 10.000 tests on my (comparatively fast system) takes 23
seconds (after optimization of the testsuite, the first try used 59
seconds).
real 0m23.088s
user 0m19.150s
sys 0m0.350s
(no errors occured on several runs ;)
The length was restricted to 200 digits. Since the entire testsuite right
now takes less than 29 seconds on my system, I fear that is still too much
for the Perl testsuite. :/
Cheers,
Tels
#!/usr/bin/perl -w
use Test;
use strict;
my $count;
BEGIN
{
$| = 1;
unshift @INC, '../lib'; # for running manually
my $location = $0; $location =~ s/mbi_rand.t//;
unshift @INC, $location; # to locate the testing files
chdir 't' if -d 't';
$count = 5000;
plan tests => $count*2;
}
use Math::BigInt;
my $c = 'Math::BigInt';
my $length = 200;
my $seed = int(rand(65537)); print "# seed: $seed\n"; srand($seed);
my ($A,$B,$ADB,$AMB,$la,$lb);
for (my $i = 0; $i < $count; $i++)
{
# length of A and B
$la = int(rand($length)+1); $lb = int(rand($length)+1);
$A = ''; $B = '';
while (length($A) < $la) { $A .= int(rand(10000)); }
while (length($B) < $lb) { $B .= int(rand(10000)); }
$A = $c->new($A); $B = $c->new($B);
# check that int(A/B)*B + A % B == A holds for all inputs
# $X = ($A/$B)*$B + $A % $B;
($ADB,$AMB) = $A->copy()->bdiv($B);
ok ($A,$ADB*$B+$AMB);
# swap 'em and try this, too
# $X = ($B/$A)*$A + $B % $A;
($ADB,$AMB) = $B->copy()->bdiv($A);
ok ($B,$ADB*$A+$AMB);
}
- --
perl -MDev::Bollocks -e'print Dev::Bollocks->rand(),"\n"'
greatly synergize high-yield paradigms
http://bloodgate.com/perl My current Perl projects
PGP key available on http://bloodgate.com/tels.asc or via email
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
iQEVAwUBPJjyK3cLPEOTuEwVAQFIpAf/UI/KKfGFcee03fuu6sH0WjMNPlDJ/iiw
nHQd/thG8/NhSoq1gSPrC7OHXJcUMRX7xxY6E8VCe5uTRVBfp2khLYl0h55+wooC
2cPesEXJN0dnmVfp7NUYBQOud+/Ouqyg+Ecjsy8P1utD4a7Y5fP+mGA26CDfiPSB
M1F/rDNAgmfLaDi54A/n7XMXb358HQQuuDJjfAEMAB2OOtNhaKKEK++KMIEvWLbY
BDxq5DiaPOeYC+gyZR4wPL6e2mcRwVDyW2gF9EUxTNEUl/pcqbJDrRK44VY2tEv1
cFxRswNk3nhnPQp5ucTFsbkML9ICaG9FzHZTApHP2mUNUNfdRVs3iA==
=jY4r
-----END PGP SIGNATURE-----