Performance issue in the loop.by rsFalse (Chaplain)
|on Feb 22, 2022 at 19:39 UTC
rsFalse has asked for the wisdom of the Perl Monks concerning the following question:
Today I tried to optimize slowest part of my program. That is inside of nested loops:
I changed the HOT-SPOT lines to:
...and my code started to work ~30 percent faster. I think it is good increase in performance but a slight decrease in readability.
I executed these code dozens of times to see how fast do they work. I observed that both programs work in not constant time and about every 10th run program occasionally consume >1.5x time than usually. I observed it on perl v5.30 and v5.32, but not on v5.14. Any ideas why every ~10th run any of these programs runs much slower?