Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix syntax error and add AKS to benchmark scripts

  • Loading branch information...
commit 829752e582379e092bbd9f605ea9e87bbd49db62 1 parent d6ffc1f
@leto authored
Showing with 11 additions and 5 deletions.
  1. +6 −3 bench/small_primes
  2. +5 −2 bench/test_large_primes
View
9 bench/small_primes
@@ -1,18 +1,21 @@
#!/usr/bin/perl -w
use strict;
+use warnings;
use Math::Pari qw/isprime/;
use Math::Primality qw/is_prime/;
+use Math::Primality::AKS qw/is_aks_prime/;
use Benchmark qw/:all/;
my $count = shift || 10000;
my $magnitude = 10;
-my @small_nums = map { "$_" } map { int(1+rand(9)) ** $magnitude) } (1..50);
+my @small_nums = map { "$_" } map { int(1+rand(9)) ** ($magnitude) } (1..50);
print "Benchmarking Math::Primality version $Math::Primality::VERSION against Math::Pari version $Math::Pari::VERSION\n";
print "Psuedorandom numbers of magnitude 10 ^ $magnitude\n";
cmpthese($count,{
- 'is_prime' => sub { is_prime($_) for @small_nums },
- 'isprime' => sub { isprime($_) for @small_nums },
+ 'Math::Primality::is_prime' => sub { is_prime($_) for @small_nums },
+ 'Math::Pari::isprime' => sub { isprime($_) for @small_nums },
+ 'Math::Primality::AKS::is_aks_prime' => sub { is_aks_prime($_) for @small_nums },
});
View
7 bench/test_large_primes
@@ -1,8 +1,10 @@
#!/usr/bin/perl -w
use strict;
+use warnings;
use Math::Primality qw/is_prime/;
use Math::Pari qw/isprime/;
+use Math::Primality::AKS qw/is_aks_prime/;
use Benchmark qw/:all/;
use Math::GMPz;
@@ -16,6 +18,7 @@ print "Benchmarking Math::Primality version $Math::Primality::VERSION against Ma
print "Psuedorandom numbers of magnitude 10 ^ $magnitude\n";
cmpthese($count,{
- 'is_prime' => sub { is_prime($_) for @nums },
- 'isprime' => sub { isprime($_) for @nums },
+ 'Math::Primality::is_prime' => sub { is_prime($_) for @nums },
+ 'Math::Pari::isprime' => sub { isprime($_) for @nums },
+ 'Math::Primality::AKS::is_aks_prime' => sub { is_aks_prime($_) for @nums },
});
Please sign in to comment.
Something went wrong with that request. Please try again.