|XP is just a number|
Re: s///eby maverick (Curate)
|on May 02, 2002 at 19:25 UTC||Need Help??|
Here's yer tuit...
This is on a 2 GHz Pentium 4. Let's say we increase $string to 1000 characters...
Benchmark: running Regexp, Regexp D&P, Substring, each for at least 5 CPU seconds... Regexp: 6 wallclock secs ( 5.29 usr + 0.00 sys = 5.29 CPU) @ 4194.33/s (n=22188) Regexp D&P: 5 wallclock secs ( 5.26 usr + 0.00 sys = 5.26 CPU) @ 2068.25/s (n=10879) Substring: 7 wallclock secs ( 5.26 usr + 0.00 sys = 5.26 CPU) @ 1022051.33/s (n=5375990)Update: Added Dog_and_Pony's solution...
Update 2:Fixed stupid bug in Substring code. , and . do different things...
Update 3:abstracts spotted that my substring function has a cut and paste error (sheesh). jsprat's benchmark is accurate. The four arg substring seems to be the fastest.