From:             starcitsura at shaw dot ca
Operating system: Linux
PHP version:      4.4.1RC1
PHP Bug Type:     Performance problem
Bug description:  Heavy "Random" Lag During foreach loop

Description:
------------
For some reason there is random lag when echoing the results.
Now I say random lightly because there seems to be a tendency for certain
items to be more likely to slow down then others, for instance at one
point I ran the script about 10 times, and item six in the list always
slowed down.

The lag seemed to occur inside the part that echoed each image and link,
at that time the lag would only occur on the image for the down button
which makes even less sense.
I used a micro time function that would echo the time since the last one
was called. The lag seemed to occur during the html portion of the code.,
which doesn’t make much sense to me.

What is causing this lag? I have also written the code so that it echo’s
the html instead of the way its done now, there was no effect on the lag

I wouldn't be worried about it if it was only like 15 milliseconds
difference, but the lag varies anywhere from 100 ms to 1500ms which is not
acceptable. Some time’s the list is as long as 100 items, in which case the
items with lag are much more common, causing the script to take as long a
10000ms.

I have tested this script on two different servers, the lag occurs on
both.
The main server uses PHP 4.3.11


Reproduce code:
---------------
foreach($array as $value)
{
  $conID = substr($value, 1);
  switch ($value{0})
  {   #simply choses which mysql query to run, then runs it  }
  list($name,$built) = $data;
  $data = new entity($name);
  $cost = $data->fetchField('Cost'); ?>
<li><?=$name;?> (<?=($cost-$built);?>/<?=$cost;?>)
<a href="?LID=<?=$LID;?>&amp;conID=<?=$value{0}.$conID;?>&amp;shift=up"
title="Up">
<img alt="Up" src="../../images/ingame/map/up.gif" height="11" width="11"
/></a>
<a href="?LID=<?=$LID;?>&amp;conID=<?=$value{0}.$conID;?>&amp;shift=x"
title="Cancel">
<img alt="Cancel" src="../../images/ingame/map/x.gif" height="11"
width="11" /></a>
</li>
<?php
}



-- 
Edit bug report at http://bugs.php.net/?id=35054&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=35054&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=35054&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=35054&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=35054&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=35054&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=35054&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=35054&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=35054&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=35054&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=35054&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=35054&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=35054&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=35054&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=35054&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=35054&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=35054&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=35054&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=35054&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=35054&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=35054&r=mysqlcfg

Reply via email to