Don't ask to ask, just ask | |
PerlMonks |
Re: Performance penalty of using qr//by kcott (Archbishop) |
on Dec 22, 2017 at 06:19 UTC ( [id://1206016]=note: print w/replies, xml ) | Need Help?? |
G'day Athanasius, I decided to look at this from a slightly different angle. Instead of involving complex routines and matches, I picked a regex match that was so simple that an 'eq' comparison would be, in normal code, a better choice:
I ran this benchmark, using that match as a base, but incorporating a whole series of variations: with/without 'qr//', the 'o' modifier, and many types of variables.
[I was aware that "qr_const_re" and "qr_const_re_o" might produce bogus results due to the additional reference and dereference operations; however, I left them in purely out of curiosity.] Here's the results just showing the rates. (The complete results are in a spoiler at the end of my post.)
Some of those numbers are too close to call with respect to what was faster than what; however, this general trend appears to emerge (fastest to slowest):
I ran that a few times. The specific order changed a bit but the general trend I've indicated seemed to hold. In light of ++dave_the_m's input, I'd like to see how captures might affect those results. I don't have time to do this myself now: perhaps you, or someone else, would care to tinker. The full results are in the spoiler, below. I needed to stretch the console window to 220 characters to avoid wrapping. <Reveal this spoiler or all in this thread>
— Ken
In Section
Seekers of Perl Wisdom
|
|