in reply to Re^5: "advanced" Perl functions and maintainability
in thread "advanced" Perl functions and maintainability
Your benchmark seems quite confused and, well, all but useful.
Your distinction between a short and long string is useless and deceptive because there are matches near both ends of the test strings for all of the searches you run, and there are no non-match data sets at all. index( $foo, $bar, 0 ) is no different from index( $foo, $bar ), neither of which does the same as /^$bar/, just like rindex( $foo, $bar ) is something entirely different from /$bar$/. You are comparing apples and meteors.
Note that putting multiple different benchmarks in a single table only serves the purpose of casting further confusion onto the data. You are benchmarking three things; run three benchmarks, look at three tables.
use re 'debug'; and compile a few regexen sometime, you'll see that the regex engine turns the trivial cases into pretty much a plain index. There's more fixed overhead for invoking the engine rather than just calling that function, of course, but on large data sets that's negligible.
Makeshifts last the longest.
|
|---|