Re: Feature Request #5919 case-insensitive version of str_replace()

From: Date: Wed, 29 Jan 2003 21:35:56 +0000
Subject: Re: Feature Request #5919 case-insensitive version of str_replace()
References: 1 2 3 4  Groups: php.dev 
Request: Send a blank email to php-dev+get-93778@lists.php.net to get a copy of this message
Ilia A. wrote:
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
What's the benchmark code? How is the benchmark difference on large text (ie. 100K of text) vs. small text (1K or smaller)? Shane

« previous php.dev (#93778) next »