Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: How to make references more like aliases?

by Prior Nacre V (Hermit)
on Sep 29, 2004 at 05:57 UTC ( #394868=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to make references more like aliases?
in thread How to make references more like aliases?

Benchmarking disagrees with you.

The closure is generated only once - my code does more here:

by_groups_of( 3, \@array ); by_groups_of( 3, [ \(@array) ] );

The closure is called multiple times - your code does more here:

return sub { \@_ }->( @$list[ $start .. $stop ] ); return [ @{$ra_list}[$start .. $stop] ];

I benchmarked on a P3/Win98 system using both Cygwin/Perl5.6 and Msys/Perl5.8. I got comparable results for both versions (no discernible speed differences). These results were repeated when volume testing with array sizes between 100,000 and 500,000.

At the end of the day, either will do nicely :-)

Regards,

PN5

Replies are listed 'Best First'.
Re^4: How to make references more like aliases?
by Limbic~Region (Chancellor) on Sep 29, 2004 at 13:29 UTC
    Prior Nacre V,
    Benchmarking disagrees with you.

    Then you misunderstood what I said. I made no claim my code was faster, only that your statement (I generally don't like passing whole arrays), seemed odd given what you were doing is more work than passing a whole array.

    Now my goal was being user-friendly, not being fast which is why I preferred $group->[1] over ${ $group->[1] }. But since you did bring up speed, my rudimentary tests show my code as being much faster. Perhaps you should try the following:

    Cheers - L~R

      This was intended to be friendly, helpful and non-competitive.

      Perhaps you could've replied in a similar vein along these lines:


      Thanks for taking the extra time to compare benchmark results. However, further testing on the intended (platform/OS/Perl version) indicates that my version will run faster and therefore I will be going with that solution.


      Instead of:

      • Using an unsubstantiated claim about what I understand. Are you psychic?
      • Including pointless rhetoric. Neither you nor I claimed your (or my) code was faster. Perhaps take a moment to consider why you added this.
      • Taking my statements out of context.
        • Yet again you have focussed on passing array vs. arrayref while ignoring what is happening in the closure.
        • Claiming I was talking about speed when I was, in fact, talking about speed differences (the former is absolute, the latter is relative).

      Finally, I very much doubt that anyone able to understand the closure generation code will have the slightest problem dereferencing a scalarref. As such, I believe your initial target for improving user-friendliness should be the closure.

      Regards,

      PN5

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://394868]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2022-05-28 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (99 votes). Check out past polls.

    Notices?