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

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

commit 5c160e03f29dabe927f6908691093ea7954d5f3b
Author: Dana Jacobsen <d...@acm.org>
Date:   Wed Jun 6 09:51:28 2012 -0600

    factoring benchmarks
---
 examples/bench-factor-semiprime.pl | 8 ++++----
 lib/Math/Prime/Util.pm             | 9 ++++-----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/examples/bench-factor-semiprime.pl 
b/examples/bench-factor-semiprime.pl
index 9942cde..70f28e8 100755
--- a/examples/bench-factor-semiprime.pl
+++ b/examples/bench-factor-semiprime.pl
@@ -21,15 +21,15 @@ die "Digits has to be >= 2 and <= 19" unless $digits >= 2 
&& $digits <= 19;
 print "Generating $numprimes random $digits-digit semiprimes (min factor 
$smallest_factor_allowed) ";
 my @semiprimes;
 foreach my $i ( 1 .. $numprimes ) {
-  my $base = 10 ** ($digits-1);
-  my $add = 10 ** ($digits) - $base;
+  my $base = int(10 ** ($digits-1));
+  my $add = int(10 ** ($digits)) - $base;
   my @factors;
   my $n;
   while (1) {
     $n = $base + int(rand($add));
-    $n++ if ($n%2) == 0;
+    next if $n > (~0 - 4);
+    $n += 1 if ($n%2) == 0;
     $n += 3 if ($n%3) == 0;
-    next if $n > ~0;
     @factors = factor($n);
     next if scalar @factors != 2;
     next if $factors[0] < $smallest_factor_allowed;
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 5ee5404..998665a 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -517,11 +517,10 @@ Perl modules, counting the primes to C<800_000_000> (800 
million), in seconds:
    [hours]  Math::Primality             0.04
 
 
-I have not done extensive timing on factoring.  The difference in speed for
-most inputs between Math::Factor::XS and Math::Prime::Util is small.  For
-some ranges M::F::XS is faster, and some ranges it is slower.  Factoring
-random semiprimes is about 1.1x to 6x faster with M::P::U, and some inputs
-are even faster (e.g. C<204518747 * 16476429743>, which is ~50x faster).
+Factoring performance depends on the input, and I'm still tuning it.  Compared
+to Math::Factor::XS, it is faster for small numbers, a little slower in
+the 7-9 digit range, and then gets much faster.  14+ digit semiprimes are
+factored 10 - 100x faster.
 
 
 =head1 AUTHORS

-- 
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