note 4652 modified in str_replace by ronabop
| From: | ronabop@php.net | Date: | Sun, 25 Feb 2001 02:00:29 +0000 |
| Subject: | note 4652 modified in str_replace by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11569@lists.php.net to get a copy of this message | ||
Benchmarking using PHP 3.0.15, preg_replace vs. str_replace.
str_replace is about 25% faster on a single match in a short string, and gets increasingly faster as
the number of matches increases. (It hits 38% on the second match...) Whole-script times for 10000
matches in a loop only showed 14% differences in runtime: if you're running a script that does
ONE match as a test, you'll see absolutely no difference in runtime.
If you're doing a lot of matching, or if your server is heavily loaded, every little bit
helps... and as a side note, doing case-insensitive preg_replace appears to be within 5% of
case-sensitive preg_replace. (Case insensitive searching is almost always slower than case
sensitive, it's just "by how much.")
http://www.php.net/manual/str-replace.php