ID: 6608
Updated by: [EMAIL PROTECTED]
Reported By: mledet at spirenet dot com
Status: Closed
Bug Type: Performance problem
Operating System: Linux 2.2.16
PHP Version: 4.0.2
New Comment:
What you need to post is a minimal testcase. If the
testcase I outlined earlier doesn't behave badly on your
system (which it does not on mine), You need to come up
with a small reproduceable _complete_ test case. Something
that I can just cut and paste into a script to duplicate
your results on my system.
Previous Comments:
------------------------------------------------------------------------
[2003-03-02 12:56:39] benji at daystream dot com
Here's more of the code, previous to the loops:
$sentence="I acn run to the store adn sing without knowing why."
$num=0;
$num++; $spell[$num]=Array(" acn "," can ");
$num++; $spell[$num]=Array(" adn "," and ");
// there are about 800 of these types of corrections. I expect you dont
want me to include them all.
My tests today show a difference of .18 seconds to 3.4 seconds. That's
about 20X slower. Better for some reason, but still not optimal by a
long shot.
------------------------------------------------------------------------
[2003-03-01 13:07:11] [EMAIL PROTECTED]
I see about a 20% overhead in executing the two loops with
a no-op inside the loop. This amount of overhead is
expected (due to the fact that your are making an extra
function call on every iteration). Nowhere near 5000%.
Tested on OSX with this:
<?php
for($i=0;$i < 100000; $i++) {
$array[] = '1';
}
for($i=0; $i < sizeof($array); $i++) {
}
?>
vs.
<?php
for($i=0;$i < 100000; $i++) {
$array[] = '1';
}
$end = sizeof($array);
for($i=0; $i < $end; $i++) {
}
?>
Your code fragment is not complete, so I cant actually
repliate your test.
------------------------------------------------------------------------
[2003-03-01 12:50:59] benji at daystream dot com
Please reopen this issue. It still exists in version 4.3.0. I'm running
on OSX. The performance with a large array that uses sizeof() in a loop
is very poor. It's abut 50X slower than it should be.
The following takes 8-10 seconds:
for ($i=1;$i<=sizeof($spell);$i++) {
$sentence=str_replace($spell[$i][0],$spell[$i][1],$sentence);
}
Whereas the following takes only .18 seconds:
$end=sizeof($spell);
for ($i=1;$i<=$end;$i++) {
$sentence=str_replace($spell[$i][0],$spell[$i][1],$sentence);
}
------------------------------------------------------------------------
[2001-05-10 05:55:09] [EMAIL PROTECTED]
No feedback. I problem exists with 4.0.5, reopen.
------------------------------------------------------------------------
[2001-04-10 10:12:23] [EMAIL PROTECTED]
Could you please test your script with either the PHP 4.0.4pl1 release,
the latest PHP 4.0.5 RC or a current CVS snapshot from
http://snaps.php.net/? Thanks.
------------------------------------------------------------------------
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/6608
--
Edit this bug report at http://bugs.php.net/?id=6608&edit=1