good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Unexplained benchmark when using chop vs. chomp (or neither)by davido (Cardinal) |
on Mar 08, 2018 at 06:00 UTC ( [id://1210503]=note: print w/replies, xml ) | Need Help?? |
The following code strives to test only chop, chomp, and a noop for the same number of iterations, with the same starting data on each iteration. As far as is practical it attempts to maintain simplicity and to establish a control group (mynada) that performs as similar an algorithm as possible to the two other alternatives. Observe this code and the results:
This produces (on my system):
This shows me that the noop is about 20%-25% faster than the other two alternatives, and that the other two are only 4% apart, which is really within the margin for error. The fact that you are getting more dramatically different results might indicate that the experiment is not as pristine as it should be, and that you are comparing non-equivalent alternatives. Dave
In Section
Seekers of Perl Wisdom
|
|