Subject: | Math::GSL::PowInt documentation and benchmarks |
1. Typo in last sentence of description "avaible" => "available"
2. Am I completely missing the point of this?
"This module is used to speed up arithmetic operations. The underlying code decomposes the multiplication in the most efficient way. Since it is implemented in XS (via SWIG), it should lend a large performance increase over the Perl builtin exponentiation operator '**'"
This makes it sound like Perl's exponentiation is in pure Perl, which isn't the case. This module is about half the speed of the builtin for Perl 5.10.1 and 5.20.0 in my tests, but of course I am not testing every system. In many cases we're comparing GSL+wrappers vs. the C library's powl(). Perhaps there is an advantage in something other than performance, or performance on odd systems?
Either way I think that paragraph needs to be rewritten.
3. Benchmark example attached. Results:
Rate PowInt n^11 PowInt r^-2 PowInt n^4 PowInt n^2 native n^11 PowInt r^2 native r^-2 native n^2 native n^4 native r^2
PowInt n^11 3843/s -- -8% -10% -12% -19% -33% -59% -60% -61% -67%
PowInt r^-2 4176/s 9% -- -2% -4% -12% -28% -56% -57% -58% -64%
PowInt n^4 4278/s 11% 2% -- -2% -10% -26% -55% -55% -57% -64%
PowInt n^2 4346/s 13% 4% 2% -- -8% -25% -54% -55% -56% -63%
native n^11 4749/s 24% 14% 11% 9% -- -18% -50% -51% -52% -60%
PowInt r^2 5767/s 50% 38% 35% 33% 21% -- -39% -40% -42% -51%
native r^-2 9425/s 145% 126% 120% 117% 98% 63% -- -2% -5% -20%
native n^2 9602/s 150% 130% 124% 121% 102% 67% 2% -- -4% -18%
native n^4 9952/s 159% 138% 133% 129% 110% 73% 6% 4% -- -15%
native r^2 11760/s 206% 182% 175% 171% 148% 104% 25% 22% 18% --
Subject: | gsl-pow-bench.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw/:all/;
use Math::GSL::PowInt qw/:all/;
my $count = shift || -1;
cmpthese($count, {
"native n^2" => sub { my $s=0; for (1..1000) { $s += $_**2; } $s; },
"PowInt n^2" => sub { my $s=0; for (1..1000) { $s += gsl_pow_2($_); } $s; },
"native n^4" => sub { my $s=0; for (1..1000) { $s += $_**4; } $s; },
"PowInt n^4" => sub { my $s=0; for (1..1000) { $s += gsl_pow_4($_); } $s; },
"native n^11" => sub { my $s=0; for (1..1000) { $s += $_**11; } $s; },
"PowInt n^11" => sub { my $s=0; for (1..1000) { $s += gsl_pow_int($_,11); } $s; },
"native r^2" => sub { my $s=1.00001; for (1..1000) { $s = $s**2; } $s; },
"PowInt r^2" => sub { my $s=1.00001; for (1..1000) { $s = gsl_pow_2($s); } $s; },
"native r^2" => sub { my $s=1.00001; for (1..1000) { $s = $s**2; } $s; },
"PowInt r^2" => sub { my $s=1.00001; for (1..1000) { $s = gsl_pow_2($s); } $s; },
"native r^-2" => sub { my $s=1.00001; for (1..1000) { $s = $s**-2; } $s; },
"PowInt r^-2" => sub { my $s=1.00001; for (1..1000) { $s = gsl_pow_int($s,-2); } $s; },
});