Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Unexplained benchmark when using chop vs. chomp (or neither)

by choroba (Bishop)
on Mar 08, 2018 at 09:37 UTC ( #1210504=note: print w/replies, xml ) Need Help??


in reply to Re: Unexplained benchmark when using chop vs. chomp (or neither)
in thread Unexplained benchmark when using chop vs. chomp (or neither)

Note that both chop and chomp can take an array as the argument. Interestingly,
chop @copy;
makes mychomp and mychop just as fast as nada.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^3: Unexplained benchmark when using chop vs. chomp (or neither)
by davido (Archbishop) on Mar 08, 2018 at 17:09 UTC

    Yes, I had considered setting up alternatives that pass an array to chomp and chop, but figured it wasn't going to be a very useful comparison for this specific situation. But absolutely, pushing the loop into internals is going to be a lot faster. In fact it wouldn't have surprised me if you had said that the array version was even faster than the 'nada' version, since the 'nada' version still has a loop, unless it's been optimized away, which I'm not sure on.


    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210504]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2018-04-19 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?