|Pathologically Eclectic Rubbish Lister|
Performance of possessive quantifiersby moritz (Cardinal)
|on Jan 27, 2008 at 18:51 UTC||Need Help??|
moritz has asked for the
wisdom of the Perl Monks concerning the following question:
Somehow I thought that the possessive quantifiers in perl 5.10 could only boost up performance, and never degrade it (neglecting a bit of overhead, perhaps). It seems that I was wrong:
You can see that the normal quantifier is the fastest, more than 20 times faster than the possessive quantifier.
I tried to decipher the -Mre=debug output, and it seems that, with a normal quantifier, the regex engine does some backtracking, so it can't be a magic optimization that immediately proves that the match fails.
Or is my benchmark flawed in some way?
So far it's not clear if 5.8.8 is caching too eagerly, or 5.10.0 too little.
It's also clear that the pattern isn't very useful, in most cases such a pattern would be anchored, in which case it's blazingly fast ;-)
I also informed our formidable porters.