Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Eily (Prior)
on Mar 08, 2018 at 09:56 UTC ( #1210505=note: print w/replies, xml ) Need Help??


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

chop will remove a character from the string each time, unless there is none. Since for aliases the variable to the list elements, the strings in @data get chopped until they are empty. As a matter of fact, since the lines are pretty short, the strings are empty before the 20th call to the function, and even without chopping, the function gets called more than 150 times

Edit: reformulated and shortened my confusing post :)

  • Comment on Re: Unexplained benchmark when using chop vs. chomp (or neither)

Replies are listed 'Best First'.
Re^2: Unexplained benchmark when using chop vs. chomp (or neither)
by Cristoforo (Curate) on Mar 08, 2018 at 15:48 UTC
    Thank you Eily. You have shown the problem that caused the results of the benchmark to be what they were.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2018-06-21 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (118 votes). Check out past polls.

    Notices?