Re: Feature Request #5919 case-insensitive version of str_replace()
| From: | Ilia A. | Date: | Wed, 29 Jan 2003 20:48:14 +0000 |
| Subject: | Re: Feature Request #5919 case-insensitive version of str_replace() | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-93774@lists.php.net to get a copy of this message | ||
> I may be wrong since I haven't profiled this, but my understanding is
> that str_replace is much faster than doing either of the regex
> replacements. For that reason alone, there is a use for it.
Normally it would be quite faster, however once case sensitivity is added to
the mix I believe the speed difference would be minimal. I've done some
benchmarks and the speed difference between str_replace() and preg_replace()
is only about 1/2 second in across 100000 executions (5 replaces per
instance). Another .6 of a second is added when preg_replace() is used with
'i' flag which makes it case insensitive. I have not benchmarked the
stri_replace code but I imagine it would be in the same ballpark, meaning
that we are adding a fairly large chunk of code for performance benefit of a
1 microsecond (1 millionth of a second) per instance.
Ilia