Yes, nslice needs an overhaul. Currently, it works by generating a slice string and then calling slice :-)
On May 22, 2013, at 2:19 AM, Kaj Wiik <[email protected]> wrote: > First, I was forced to use Matlab for a while (I used it before moving > perl and PDL). I had forgotten how cubersome it is to express > algorithms compared to PDL. Cheers to all PDL developers!! > > While ago (indeed with using Devel::NYTProf) I noticed that ->slice() > is much faster than NiceSlice and nslice: > > use PDL; > use PDL::NiceSlice; > use Benchmark qw(:all); > > $count = 100000; > $a = zeroes(100); > $results = timethese($count, > { > 'slice' => sub { my $b = $a->slice("5:50"); }, > 'NiceSlice' => sub { my $b = $a(5:50); }, > 'nslice' => sub { my $b = $a->nslice([5,50]); }, > }, > 'none' > ); > cmpthese( $results ) ; > > > Rate NiceSlice nslice slice > NiceSlice 48544/s -- -11% -75% > nslice 54348/s 12% -- -72% > slice 192308/s 296% 254% -- > > Also (a trivial thing) growing a piddle is very expensive, > preallocating is much faster, but that is trivial. Perhaps worth of > emphasizing in documentation. > > Cheers, > Kaj > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
