the regex $str =~ /foo/ devolves to something pretty much like Index $str, 'foo'
Yes exactly. Itll be a little slower than a index but only becuase there is a longer codepath from the regex-opcode to the actual FBM search than from the index-opcode.
The surprise is how fast using a character set with a common prefix match is. That result also goes a long way to validating the benchmark.
And it illustrates a new optimisation in 5.10:
Rate using_alt_match using_or_nomatch using_alt_ +nomatch using_or_match using_alt_match 412710/s -- -29% + -30% -36% using_or_nomatch 580306/s 41% -- + -1% -9% using_alt_nomatch 585631/s 42% 1% + -- -9% using_or_match 640118/s 55% 10% + 9% -- 1631660
Basically 5.10 is smart enough to convert /baz|bar/ into something close to /ba[rz]/. Its not quite as fast when written as an alternation due to current implmentation details, but it is very close.
In reply to Re^2: Benchmarking regex alternation
by demerphq
in thread Benchmarking regex alternation
by Tanktalus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |