Here is the affected code
- Code: Select all
- <?php
list($usec, $sec) = explode(" ",microtime());
$start = ((float)$usec + (float)$sec);
$queue = trim(GetAmountOfResource('Queue',$LID));
list($usec, $sec) = explode(" ",microtime());
$time1 = (float)$usec + (float)$sec;
echo 'Queue Grab Time: '.round(($time1 - $start)*1000,3);
if(!empty($queue))
{
$array = explode(' ',trim($queue));
list($usec, $sec) = explode(" ",microtime());
$time2 = (float)$usec + (float)$sec;
echo '
Queue Explode Time: '.round(($time2 - $time1)*1000,3);
foreach($array as $value)
{
$conID = substr($value, 1);
switch ($value{0})
{
case 'i' :
$data = mysql_fetch_array(mysql_query('SELECT `ImprovementType`,`Built` FROM `improvements` WHERE `ImprovementID` = '.$conID));
break;
case 'u' :
$data = mysql_fetch_array(mysql_query('SELECT `UnitType`,`Built` FROM `units` WHERE `UnitID` = '.$conID));
break;
}
list($usec, $sec) = explode(" ",microtime());
$time3 = (float)$usec + (float)$sec;
$report = '
Switch Time: '.round(($time3 - $time2)*1000,3);
$time2=$time3;
list($name,$built) = $data;
$data = new entity($name);
$cost = $data->fetchField('Cost');
list($usec, $sec) = explode(" ",microtime());
$time3 = (float)$usec + (float)$sec;
$report .= '
Process Time: '.round(($time3 - $time2)*1000,3);
$time2=$time3;
echo '
- '.$name.' ('.($cost-$built).'/'.$cost.')';
echo '<a href="?LID='.$LID.'&conID='.$value{0}.$conID.'&shift=up" title="Up">';
echo '[img]../../images/ingame/map/up.gif[/img]</a>';
echo '<a href="?LID='.$LID.'&conID='.$value{0}.$conID.'&shift=down" title="Down">';
echo '[img]../../images/ingame/map/down.gif[/img]</a>';
echo '<a href="?LID='.$LID.'&conID='.$value{0}.$conID.'&shift=x" onclick="if (!confirm(\'Remove from the queue?\nAll production will be lost!\')) { return false; }" title="Cancel">';
echo '[img]../../images/ingame/map/x.gif[/img]</a>';
list($usec, $sec) = explode(" ",microtime());
$time3 = (float)$usec + (float)$sec;
echo $report.'
Display Time: '.round(($time3 - $time2)*1000,3).'
';
$time2=$time3;
echo '';
}
}
echo '
';
And the output
- Code: Select all
Queue Grab Time: 0.266
# Queue Explode Time: 0.059Iron Mine (0/200)UpDownCancel
Switch Time: 0.254
Process Time: 0.479
Display Time: 0.063
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.212
Process Time: 0.451
Display Time: 0.058
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.2
Process Time: 0.45
Display Time: 0.058
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.205
Process Time: 0.44
Display Time: 0.057
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.199
Process Time: 0.438
Display Time: 0.058
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.194
Process Time: 0.444
Display Time: 0.057
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.202
Process Time: 0.444
Display Time: 199.761
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.362
Process Time: 0.492
Display Time: 0.08
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.253
Process Time: 0.464
Display Time: 0.074
# Iron Mine (0/200)UpDownCancel
Switch Time: 0.233
Process Time: 0.466
Display Time: 0.059
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.
I had more time takers 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.
What is causing this lag? I have rewritten the code a couple ways thinking maybe it was just the way it was done but they had little or no change.
I wouldn't be worried about it if it was only like 15 milliseconds diffrence, but the lag verries anywhere from 100 ms to 1500ms which is not acceptable.[/list][/list]