Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: 5:10: Why is this slower than 5.8.8?

by doom (Deacon)
on Dec 23, 2007 at 06:03 UTC ( #658747=note: print w/ replies, xml ) Need Help??


in reply to 5:10: Why is this slower than 5.8.8?

A few comments:

That assign from @_ idiom may still be relatively common, but it's not recommended these days. While Conway does use the @_ assign throughout his "Object Oriented Perl", now his "Perl Best Practices" recommends using shift to access @_.

And myself, I'm having trouble reproducing this problem at present. I just made a quick try at comparing assigning an array vs shifting off of an array, and I find that they've both gotten slightly faster under perl 5.9.5 vs perl 5.8.8 on my AMD64 based laptop, running kubuntu (linux kernel: 2.6.22-14-generic).

And incidentally, I see that the "shift" method is around 30% faster than assign from array.

(Benchmark code available upon request. At present I'm just skipping it because it's fairly dull.)


Comment on Re: 5:10: Why is this slower than 5.8.8?
Re^2: 5:10: Why is this slower than 5.8.8?
by jk2addict (Chaplain) on Dec 23, 2007 at 17:03 UTC
    There's a big diference between 'common/not recommended', and almost 50% slower. And with all due respect to PBP, using three lines of shift instead of = @_ is just silly in some ways. To each their own.
      Well, obviously it would be better if there wasn't a speed penalty associated with array assigns, but since there is it might be better to live with the extra lines of shifts, even if they seem inelegant.

      Anyway, the main point is that we should probably assume that this is a FreeBSD oddity of some sort (ala the "malloc" issue under discussion), unless someone chimes in with some data that shows the contrary.

Re^2: 5:10: Why is this slower than 5.8.8?
by Argel (Prior) on Dec 27, 2007 at 20:39 UTC
    Where does he say that? Looking at page 180 of PBP TheDamian recommends using the shift idiom if you need to comment or sanity check one of the variables, but otherwise either the my()=@_ or the shift idioms are okay. The only thing he really recommends against is accessing @_ directly (e.g. $_[1]).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-04-19 22:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls