http://www.perlmonks.org?node_id=840660


in reply to Re: Unefficient Regexp 'Matching this or that'
in thread Unefficient Regexp 'Matching this or that'

Maybe it shoudl be possible to disable the trie optimisation for thos cases of alternation where it doesn't benefit.
Maybe you can disable trie optimizations by setting ${^RE_TRIE_MAXBUF} = 0?
Perl 6 - links to (nearly) everything that is Perl 6.
  • Comment on Re^2: Unefficient Regexp 'Matching this or that'

Replies are listed 'Best First'.
Re^3: Unefficient Regexp 'Matching this or that'
by BrowserUk (Patriarch) on May 19, 2010 at 10:33 UTC

    That seems to work. !5 seconds instead of 53 for the alternation is much more reasonable. Still doesn't beat the two pass method, but there is probably a break point somewhere.

    c:\test>junk31 836952.log Benchmark: timing 1 iterations of AAtwo_pass, BBtwo_string, CCone_string ... two pass: 10 AAtwo_pass: 7 wallclock secs ( 5.60 usr + 0.83 sys = 6.43 CPU) @ 0 +.16/s (n=1) (warning: too few iterations for a reliable count) two string: 10 BBtwo_string: 15 wallclock secs (14.35 usr + 0.94 sys = 15.29 CPU) @ + 0.07/s (n=1) (warning: too few iterations for a reliable count) one string: 7 CCone_string: 16 wallclock secs (14.76 usr + 0.73 sys = 15.49 CPU) @ + 0.06/s (n=1) (warning: too few iterations for a reliable count)

    I'm still puzzled why the two pass takes less time than the one string, but the numbers are right and I can't anything major wrong with the benchmark?