Curt Zirzow wrote:

* Thus wrote Oliver Hankeln ([EMAIL PROTECTED]):

100000 Searches in a rather small string took
0.38s with strpos() and 0.55s with preg_match()


Make sure your benchmarks aren't bias: - assignment takes time - concating string takes time

You are right. I updated the script to: [...] $regexp="/".$needle."/"; $t1=getmicrotime(); for($i=0;$i<100000;$i++) strpos($haystack,$needle); $t2=getmicrotime(); for($i=0;$i<100000;$i++) preg_match($regexp,$haystack); $t3=getmicrotime(); [...]

Now the time is 0.33s vs. 0.46s.
preg_match needs 139.4% of the strpos time

Oliver

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to