[libmath-prime-util-perl] 11/72: Add output comments to primesarray bench

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:49:36 UTC 2015


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

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

commit 65ea92e5971b43e5c3d2e992883142d45423b6dc
Author: Dana Jacobsen <dana at acm.org>
Date:   Fri Aug 16 17:55:03 2013 -0700

    Add output comments to primesarray bench
---
 README                       |  7 ++++---
 examples/bench-primearray.pl | 16 +++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/README b/README
index 8f2cf60..0501b68 100644
--- a/README
+++ b/README
@@ -17,7 +17,8 @@ Current measurements show it is faster than:
   Math::Prime::TiedArray
   Crypt::Primes
 For non-bignums, it is typically faster than Math::Pari (and doesn't
-require Pari to be installed).
+require Pari to be installed).  With Math::Prime::Util::GMP installed
+it is usually faster than Math::Pari for bigints;
 
 
 SYNOPSIS
@@ -27,8 +28,8 @@ SYNOPSIS
   # Get a big array reference of many primes
   my $aref = primes( 100_000_000 );
 
-  # All the primes between 5k and 10k inclusive
-  my $aref = primes( 5_000, 10_000 );
+  # All the primes between 5k and 10k inclusive in a regular array
+  my @primes = @{ primes( 5_000, 10_000 ) };
 
 See the POD module documentation for examples and more information on all the
 methods included.
diff --git a/examples/bench-primearray.pl b/examples/bench-primearray.pl
index 028288e..ca6aba5 100755
--- a/examples/bench-primearray.pl
+++ b/examples/bench-primearray.pl
@@ -12,7 +12,12 @@ my $count = shift || -2;
 my ($s, $nlimit, $ilimit, $expect);
 
 if (1) {
+print '-' x 79, "\n";
 print "summation to 100k\n";
+print "Note: MPU::PrimeArray is about 30x faster than MPTA here.\n";
+print "      It seems slices are the fastest way to access the tied array\n";
+print "      Math::NumSeq::Primes is reasonable fast (not random access)\n";
+print "      MPU's forprimes smashes everything else (not random access)\n";
 $nlimit = 100000;
 $ilimit = prime_count($nlimit)-1;
 $expect = 0; forprimes { $expect += $_ } $nlimit;
@@ -49,8 +54,11 @@ cmpthese($count,{
 }
 
 if (0) {
+print '-' x 79, "\n";
 print "summation to 10M\n";
-print "Skipping Math::Prime::TiedArray as it will take too long\n";
+print "Note: Math::Prime::TiedArray takes too long\n";
+print "      Math::NumSeq::Primes is now ~2x slower than PrimeArray\n";
+print "      forprimes is still the fastest solution for sequential access\n";
 $nlimit = 10_000_000;
 $ilimit = prime_count($nlimit)-1;
 $expect = 0; forprimes { $expect += $_ } $nlimit;
@@ -80,7 +88,9 @@ cmpthese($count,{
 }
 
 if (1) {
+print '-' x 79, "\n";
 print "Walk primes backwards from 1M\n";
+print "Note: MPTA takes 4x longer than just calling MPU's nth_prime!\n";
 $nlimit = 1_000_000;
 $ilimit = prime_count($nlimit)-1;
 $expect = 0; forprimes { $expect += $_ } $nlimit;
@@ -98,7 +108,9 @@ cmpthese($count,{
 }
 
 if (1) {
+print '-' x 79, "\n";
 print "Random walk in 1M\n";
+print "MPTA takes about 2 minutes and lots of RAM per iteration.\n";
 srand(29);
 my @rindex;
 do { push @rindex, int(rand(1000000)) } for 1..10000;
@@ -115,3 +127,5 @@ cmpthese($count,{
   #                     die unless $s == $expect; },
 });
 }
+
+print '-' x 79, "\n";

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



More information about the Pkg-perl-cvs-commits mailing list