Script Process Time

This is a discussion on "Script Process Time" within the PHP Forum section. This forum, and the thread "Script Process Time are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 18th, 2005, 22:56
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Script Process Time

Here is the affected code
Code: Select all
  1. <?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 '
  2. '.$name.' ('.($cost-$built).'/'.$cost.')'; echo '<a href="?LID='.$LID.'&amp;conID='.$value{0}.$conID.'&amp;shift=up" title="Up">'; echo '[img]../../images/ingame/map/up.gif[/img]</a>'; echo '<a href="?LID='.$LID.'&amp;conID='.$value{0}.$conID.'&amp;shift=down" title="Down">'; echo '[img]../../images/ingame/map/down.gif[/img]</a>'; echo '<a href="?LID='.$LID.'&amp;conID='.$value{0}.$conID.'&amp;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]
Reply With Quote

  #2 (permalink)  
Old Oct 19th, 2005, 01:01
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sypher
Have you tried limiting the number of echos and using a
inside the echo so that it only has to use the function once.
Reply With Quote
  #3 (permalink)  
Old Oct 19th, 2005, 06:22
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Well since all the data is displayed as one line on the page useing a
wouldn't be what I want, however,

I originaly had it as
[*]<?=$name;?>(<?=($cost-$built);?>/<?=$cost;?>)
<a href="?LID=<?=$LID;?>&amp;conID=<?=$value{0}.$conI D;?>&amp;shift=up" title="Up">
etc

this actualy ran about .01 of a second faster, but the long lag was still happening. I don't see how reduceing the number of echo's would efect the lag, but I will test it tomorow, and report back.
Reply With Quote
Reply

Tags
script, process, time

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Form - email won't process tinggg Classic ASP 7 Nov 28th, 2007 10:37
can get php to process my form, why? enrique PHP Forum 15 Dec 6th, 2006 19:52
Updating multiple records at the same time prob. with script at51178 Classic ASP 11 Feb 1st, 2006 17:56
Server time and date script gribble JavaScript Forum 1 Aug 16th, 2005 09:53
Adjusting time from server time to local time Tim356 Classic ASP 10 Jun 21st, 2004 14:57


All times are GMT. The time now is 11:41.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43