Problems? Is your data what you think it is? | |
PerlMonks |
Re^2: Benchmarks aren't everything (rewritten regex is 290% faster than original)by demerphq (Chancellor) |
on Oct 25, 2005 at 08:16 UTC ( [id://502645]=note: print w/replies, xml ) | Need Help?? |
As a follow up here is a benchmark of the regex as posted against the equivelent regex that uses classes and not alternation, note the drammatic difference in run time. ($rex1 is the regex without alternations, $rex2 is the regex as posted, with newlines inserted to make it moderately easier to read)
which has the following output:
So by removing the alternation we see a 290% speedup. What was the run time difference in the benchmark being referenced? Well apparently Java took 244 seconds and Perl took 527, which afaict (my maths arent so hot) is %115 faster. Now perhaps Java also would benefit from this modest optimisation of his code, but perhaps not, perhaps the Java implementation does this internally and in fact would not see an improvement. Either way the case does not seem to be proved at all. BTW, for my benchmarks i just used the source for a page of Perlmonks. Use whatever XML/HTML you like.
--- $world=~s/war/peace/g
In Section
Meditations
|
|