in reply to Re: Performance issue in the loop.
in thread Performance issue in the loop.
Moar PDL!
Here's my tweak of vr's excellent code, for use in the perldl REPL, which doesn't feature the check, just does timing (and doesn't use strict because of the REPL), and uses "+=" instead of the wordier "->inplace->plus":
I also increased the $n.$n = 2e4; @input = map int rand 1e5, 1 .. $n; $sums = zeroes long, scalar @input; $vec = pdl long, \@input; with_time { my @max = map +($sums( 0 : -$_ - 1 ) += $vec( $_ : -1 ))-> +maximum, 0 .. $#input };
EDIT: in PDL 2.077 with_time is always available in the PDL shells so I removed the definition of it here.
|
---|
In Section
Seekers of Perl Wisdom