Forum Moderators: coopster

Message Too Old, No Replies

this page took . to generate

how is it done?

         

dmmh

7:28 pm on Sep 25, 2005 (gmt 0)

10+ Year Member



Ive seen it on a couple of sites. I would be interested in this, but not only for a search or something. Basically I want it somewhere on all pages, so it should compute how long it takes for PHP to generate the entire page, including the time thats wasted building up content gathered from MySQL queries

jamie

7:41 pm on Sep 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

we insert right at the top of the main php script (before any includes)

// function to measure speed of page
function getmicrotime($t)
{
list($usec, $sec) = explode(" ",$t);
return ((float)$usec + (float)$sec);
}
$starttime = microtime();

then at the bottom

$endtime = microtime();
$diff = getmicrotime($endtime) - getmicrotime($starttime);

then you echo out $diff. i didn't code this myself but just copied from somewhere ;)

Eltiti

8:07 pm on Sep 25, 2005 (gmt 0)

10+ Year Member



Other than for debugging purposes, is there any "advantage" in displaying that information? To me, it always feels a bit like the "awards we've won" page on some sites... :-)

dmmh

8:20 pm on Sep 25, 2005 (gmt 0)

10+ Year Member



it is for debugging purposes :p
aside from that, it looks cool, I think, cant help it :)

dmmh

8:20 pm on Sep 25, 2005 (gmt 0)

10+ Year Member



ow and btw jamie: thx, Ill try it