in reply to Re: How useful is the /o regexp modifier?
in thread How useful is the /o regexp modifier?

your cases are pretty pathologic

I think that's my problem. What I'd like is a regex that's hard to compile, but what I made instead are ones that are hard to match. Not knowing anything about the compilation process, I don't know how to design something that will take a long time to compile (and match quickly) so as to show the compilation step.

  • Comment on Re^2: How useful is the /o regexp modifier?

Replies are listed 'Best First'.
Re^3: How useful is the /o regexp modifier?
by jethro (Monsignor) on Feb 04, 2009 at 14:19 UTC

    How about these:

    m{.|<long pattern>} m{\!<long pattern>} # with ! not anywhere in the string you match

    Both will match any long pattern very fast, the first one should be the fastest match possible as it matches just the first char of the string to match.

    It could be that the long patterns are optimized away, that should be tested

    UPDATE: On second thought, whether they are optimized away doesn't really matter as long as the compilation takes more time, and it does, at least with perl 5.8.8

    #with short pattern m{.|U*e?Z+} horrid rx matches string Rate // qr/o qr /o // 1254/s -- -29% -30% -34% qr/o 1771/s 41% -- -1% -7% qr 1781/s 42% 1% -- -7% /o 1912/s 52% 8% 7% -- #with long pattern m{.|U*e?Z+J{0,1}z*4{0,1}7?d*H+k*l+N+d{0,1}4+9{0,1} +... 1000 more subpattern horrid rx matches string Rate // qr qr/o /o // 235/s -- -87% -87% -88% qr 1770/s 654% -- -1% -7% qr/o 1781/s 659% 1% -- -7% /o 1912/s 715% 8% 7% --