Hi!

Another surprise that I noticed: complex piddle structure comes with a price:

use PDL;
use PDL::NiceSlice;
use Benchmark qw(:all);

$count = 100;
$a = zeroes(1e7);
$b = $a(0:-1);
$b->reshape(2,5,2,5,2,5,2,5,2,5,2,5,2,5);

$results = timethese($count,
             {
             '1d' => sub { $a += 1; },
             '14d' => sub { $b += 1; },
             '14d + flat' => sub { $c = $d->clump(-1); $d += 1; },
             },
             'none'
    );

}
cmpthese( $results ) ;

             Rate        14d         1d 14d + flat
14d        3.86/s         --       -89%       -90%
1d         36.8/s       852%         --        -0%
14d + flat 36.9/s       856%         0%         --

Flattening before doing operations to all elements of a
multidimensional piddle is much faster.

Cheers,
Kaj

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to