This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.30
in repository libmath-prime-util-perl.

commit 6bf74f6ab3128598af1b874780d54797c5ba4daf
Author: Dana Jacobsen <d...@acm.org>
Date:   Thu Jul 11 17:34:21 2013 -0700

    Update some benchmarks
---
 examples/bench-factor-extra.pl |  4 +++-
 examples/bench-isprime-bpsw.pl | 35 ++++++++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/examples/bench-factor-extra.pl b/examples/bench-factor-extra.pl
index 98d3342..674ce19 100755
--- a/examples/bench-factor-extra.pl
+++ b/examples/bench-factor-extra.pl
@@ -56,6 +56,7 @@ sub test_at_digits {
     $nfactored{'prho'} += $calc_nfacs->(Math::Prime::Util::prho_factor($_, 
$rounds));
     $nfactored{'pbrent'} += $calc_nfacs->(Math::Prime::Util::pbrent_factor($_, 
$rounds));
     $nfactored{'pminus1'} += 
$calc_nfacs->(Math::Prime::Util::pminus1_factor($_, $p1smooth));
+    $nfactored{'pplus1'} += $calc_nfacs->(Math::Prime::Util::pplus1_factor($_, 
$p1smooth));
     $nfactored{'squfof'} += $calc_nfacs->(Math::Prime::Util::squfof_factor($_, 
$sqrounds));
     $nfactored{'rsqufof'} += 
$calc_nfacs->(Math::Prime::Util::rsqufof_factor($_, $rsqrounds));
     #$nfactored{'trial'} += $calc_nfacs->(Math::Prime::Util::trial_factor($_));
@@ -74,7 +75,8 @@ sub test_at_digits {
     "prho"    => sub { Math::Prime::Util::prho_factor($_, $rounds) for @nums },
     "pbrent"  => sub { Math::Prime::Util::pbrent_factor($_, $rounds) for @nums 
},
     "pminus1" => sub { Math::Prime::Util::pminus1_factor($_, $rounds) for 
@nums },
-    "fermat"  => sub { Math::Prime::Util::fermat_factor($_, $rounds) for @nums 
},
+    "pplus1"  => sub { Math::Prime::Util::pplus1_factor($_, $rounds) for 
@nums},
+    "fermat"  => sub { Math::Prime::Util::fermat_factor($_, $rounds) for 
@nums},
     "holf"    => sub { Math::Prime::Util::holf_factor($_, $hrounds) for @nums 
},
     "squfof"  => sub { Math::Prime::Util::squfof_factor($_, $sqrounds) for 
@nums },
     "rsqufof" => sub { Math::Prime::Util::rsqufof_factor($_) for @nums },
diff --git a/examples/bench-isprime-bpsw.pl b/examples/bench-isprime-bpsw.pl
index ca9a61a..62ce29b 100755
--- a/examples/bench-isprime-bpsw.pl
+++ b/examples/bench-isprime-bpsw.pl
@@ -6,18 +6,33 @@ $| = 1;  # fast pipes
 use Math::Prime::Util;
 use Math::Primality;
 
+my $count = shift || -1;
+
 # GMP is ~3x faster than Calc or Pari for these operations
 use bigint try=>'GMP';
 srand(500);
-use Math::BigInt::Random::OO;
-my $gen = Math::BigInt::Random::OO -> new(length => 80);
-#my $gen = Math::BigInt::Random::OO -> new(length => 8);
+use Config;
+
+my $rgen = sub {
+  my $range = shift;
+  return 0 if $range <= 0;
+  my $rbits = 0; { my $t = $range; while ($t) { $rbits++; $t >>= 1; } }
+  while (1) {
+    my $rbitsleft = $rbits;
+    my $U = $range - $range;  # 0 or bigint 0
+    while ($rbitsleft > 0) {
+      my $usebits = ($rbitsleft > $Config{randbits}) ? $Config{randbits} : 
$rbitsleft;
+      $U = ($U << $usebits) + int(rand(1 << $usebits));
+      $rbitsleft -= $usebits;
+    }
+    return $U if $U <= $range;
+  }
+};
 
 my @rns;
 while (@rns < 50) {
-  # Ensure $n is an object of our bigint class, not MBROO's choice.
-  my $n = Math::BigInt->new( $gen->generate()->bstr );
-  $n++ if ($n % 2) == 0;    # Math::BigInt::Random::OO keeps making evens 
(bug?)
+  my $n = $rgen->( Math::BigInt->new(2)->bpow(81) );
+  $n++ if ($n % 2) == 0;
   next unless ($n % 2) != 0;
   push @rns, $n;
 }
@@ -36,12 +51,14 @@ print "OK\n";
 
 use Benchmark qw/:all/;
 my $sum = 0;
-cmpthese(-2, {
+cmpthese($count, {
   "MP  MR" => sub { $sum += Math::Primality::is_strong_pseudoprime("$_","2") 
for @rns; },
-  "MPU MR" => sub { $sum += Math::Prime::Util::is_strong_pseudoprime($_,2) for 
@rns; },
+  "MPU MR" => sub { $sum += 
Math::Prime::Util::GMP::is_strong_pseudoprime($_,2) for @rns; },
   #"MPUxMR" => sub { Math::Prime::Util::miller_rabin($_,2) for @rns; },
   "MP  LP" => sub { $sum += Math::Primality::is_strong_lucas_pseudoprime("$_") 
for @rns;},
-  "MPU LP" => sub { $sum += Math::Prime::Util::is_strong_lucas_pseudoprime($_) 
for @rns;},
+  "MPU LP" => sub { $sum += 
Math::Prime::Util::GMP::is_strong_lucas_pseudoprime($_) for @rns;},
+  "MPU ELP" => sub { $sum += 
Math::Prime::Util::GMP::is_extra_strong_lucas_pseudoprime($_) for @rns;},
+  #"MPU AELP" => sub { $sum += 
Math::Prime::Util::GMP::is_almost_extra_strong_lucas_pseudoprime($_) for @rns;},
   "MP  IP" => sub { $sum += Math::Primality::is_prime("$_") for @rns;},
   "MPU IP" => sub { $sum += Math::Prime::Util::is_prime($_) for @rns;},
   #"MPUxIP" => sub { Math::Prime::Util::is_prime($_) for @rns;},

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to