Edit report at http://bugs.php.net/bug.php?id=45265&edit=1

 ID:               45265
 Updated by:       paj...@php.net
 Reported by:      marc at phpmyadmin dot net
 Summary:          stripos() very slow
-Status:           Assigned
+Status:           Bogus
 Type:             Bug
 Package:          Performance problem
 Operating System: win32 only
 PHP Version:      *
 Assigned To:      pajoye

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

After having analyzed the problem, it seems to be the windows
implementation that has serious performance problems in comparison to
libc. Nothing we can do against that.


Previous Comments:
------------------------------------------------------------------------
[2009-02-11 15:05:10] foruns at dan dot mus dot br

I'm running PHP 5.2.6 in a G4 iBook PPC and I'm experiencing extremely
low performance using that function. 



I intended to use stripos() inside a loop to retrieve the positions of
multiple DIV elements in a HTML page, increasing the offset value
accordingly.



But, on a 64kb document, it would take from 0.4sec to 2.5sec to find
each "<div" string.



Strpos() would take as little as 0.004sec on the same document.



Daniel

------------------------------------------------------------------------
[2008-08-11 00:34:09] ni...@php.net

And according to
http://msdn.microsoft.com/en-us/library/8h19t214(VS.80).aspx _tolower's
Windows implentation isn't ANSI.

------------------------------------------------------------------------
[2008-08-11 00:15:45] ni...@php.net

Nice work Pierre but according to MSDN and yourself, _tolower's Windows
implementation is clearly faster than tolower but has undefined results
if the character is not ASCII... And we can't rely on that... can we?



According to libc, tolower checks the locale too... And _lower on libc
is quite different than Windows's since the _tolower() function is
identical to tolower() except that c must be an upper-case letter.



So...

------------------------------------------------------------------------
[2008-08-10 23:41:53] paj...@php.net

The problem is that the Windows API does check for the locale while
processing the string (isupper, islower used by tolower or toupper).



Using _tolower/_toupper only speed up the functions using it (as fast or
faster than linux). But it does not work for non ASCII input.



I have to check is libc does check for locale as well, if not, I will
happily use _tolower on windows too.



That being said, it may be used too in zend then. tolower is used *many*
times there.

------------------------------------------------------------------------
[2008-08-10 17:01:44] ni...@php.net

It seems it's a php_strtolower() issue because we have the same problem
by replacing stripos to strtolower...



The problem occurs on Windows also with strtolower()...



71 seconds on Windows, 25s on linux...



Reproduce code:

$a = str_repeat('x', 100000);

for ($i = 0; $i < 10000; $i++) {

        $b = strtolower($a);

}



------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=45265


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=45265&edit=1

Reply via email to