Perl: the Markov chain saw | |
PerlMonks |
Re^5: how to count the number of repeats in a string (really!)by oha (Friar) |
on Nov 15, 2007 at 11:22 UTC ( [id://650947]=note: print w/replies, xml ) | Need Help?? |
Admittedly, it would be interesting to see how the benchmark goes with different data sets...I used the following text, not big but should be enough After reading the code of ikegami and lodin, "I personally believe"d they were faster but i was wrong: I suspect the regex engine is so much smarter in finding fixed char repetition to gain more then the gain of doing lots regex call... Oha PS: i didn't passed the string to the subs and didn't returned the results. Update: removed the \n from the string, updated results
Update: my code is broken: it must reset pos to the previous pos+1 (if not some subpatterns aren't matched). updated results are as "i personally believe"d:
In Section
Seekers of Perl Wisdom
|
|