No, I'm just not very experienced with Benchmarks. :-) I'll look into it later today. On Apr 19, 2012 4:29 PM, "Chris Marshall" <[email protected]> wrote:
> I notice you are still running a very small > amount of timings. How are your timings > if you change the -1 to -10 in cmpthese? > Is there a specific reason to leave that off > of the update? > > --Chris > > > On Thu, Apr 19, 2012 at 5:11 PM, David Mertens <[email protected]> > wrote: > > Wow, that makes a sizeable difference, especially for larger values of > > $updates_per_round, where it doesn't need to constantly re-allocate > > temporary memory. I've updated the post to reflect that. > > > > Thanks, Chris! > > David > > > > > > On Thu, Apr 19, 2012 at 3:19 PM, Chris Marshall <[email protected]> > > wrote: > >> > >> I don't have a stackoverflow.com account but if I use > >> your original test code, increase the cpu seconds for > >> the benchmark and replace the dataflow increment > >> code by the indadd() routine, I get speeds from 50X > >> for $N=1, down to 1.9X for $N=1000, and then up to > >> 3-4X as the sizes increase to 10000000 where I > >> stopped testing. > >> > >> The key here is to avoid creating and destroying piddles > >> since the computational work involved here is *very* > >> light. In fact, an Inline::PP routine to handle the core > >> of an algorithm of interest (if more than indadd) + the > >> existing PDL should perform very well for this use > >> case---according to the benchmarks on my system: > >> > >> use PDL; > >> use Benchmark qw/cmpthese/; > >> > >> my $updates_per_round = shift || 1; > >> > >> my $N = 1_000_000; > >> my @perl = (0 .. $N - 1); > >> my $pdl = zeroes $N; > >> > >> cmpthese(-10,{ > >> perl => sub{ > >> $perl[int(rand($N))]++ for (1..$updates_per_round); > >> }, > >> pdl => sub{ > >> my $to_update = long(random($updates_per_round) * $N); > >> indadd(1,$to_update,$pdl); > >> ## $pdl->index($to_update)++; > >> } > >> }); > >> > >> > >> Cheers, > >> Chris > >> > >> On Wed, Apr 18, 2012 at 10:11 AM, David Mertens > >> <[email protected]> wrote: > >> > Hey folks - > >> > > >> > There's a PDL question on stack overflow > >> > (http://stackoverflow.com/questions/9730678/c-like-arrays-in-perl) to > >> > which > >> > I submitted an answer. I believe my answer is better than the > currently > >> > marked best answer, but it looks like the OP either disagrees or > simply > >> > has > >> > not returned to read my answer. I would appreciate if those of you who > >> > have > >> > stack overflow accounts could read the responses and up-vote what you > >> > think > >> > is the best answer. > >> > > >> > Thanks! > >> > David > >> > > >> > -- > >> > "Debugging is twice as hard as writing the code in the first place. > >> > Therefore, if you write the code as cleverly as possible, you are, > >> > by definition, not smart enough to debug it." -- Brian Kernighan > >> > > >> > > >> > _______________________________________________ > >> > Perldl mailing list > >> > [email protected] > >> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > >> > > > > > > > > > > > -- > > "Debugging is twice as hard as writing the code in the first place. > > Therefore, if you write the code as cleverly as possible, you are, > > by definition, not smart enough to debug it." -- Brian Kernighan > > >
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
