in reply to Why is Perl suddenly slow in THIS case?
Ignore this: I misread (inverted) the meaning of the results.
<
I get similar results to you using 5.22:
C:\test>\Perl22\bin\perl.exe 1183703.pl Rate Q R Q 1.29/s -- -96% R 34.9/s 2595% --
And more consistent, but slower results using 5.10:
C:\test>1183703.pl Rate R Q R 46.0/s -- -1% Q 46.7/s 1% --
My conclusion is that some recent optimisation helps enormously with your Q example, and somewhat, but less so with your R example.
I hazard a guess that the optimisation is a fast linear search for the presence of any constant bits of the regex means the Q example is very fast -- the R constant isn't there.
But for the R example, the constant 'R' is present, so the regex engine needs to be fired up, and it probably checks for the presence of one or more digits preceding every occurrence of 'R' in the string.
Other than adding another optimisation to detect that the string doesn't contain any digits -- a difficult thing to generalise -- you should probably be rejoicing in the optimisation that speeds up the Q case, rather than complaining that it doesn't help in the R case.
|
|---|