Calculate Webpage Load Time in PHP

Post Reply
User avatar
Shane
Captain
Captain
Posts: 226
Joined: Sun Jul 19, 2009 9:59 pm
Location: Jönköping, Sweden

Calculate Webpage Load Time in PHP

Post by Shane » Fri Sep 04, 2009 3:26 am

Paste following code at the beginning of the page.

Code: Select all

$m_time = explode(" ",microtime()); 
$m_time = $m_time[0] + $m_time[1]; 
$loadstart = $m_time;
 
Paste following code at the end of the page.

Code: Select all

$m_time = explode(" ",microtime()); 
$m_time = $m_time[0] + $m_time[1]; 
$loadend = $m_time; 
$loadtotal = ($loadend - $loadstart); 
echo "<small><em>Generated page in ". round($loadtotal,3) ." seconds</em></small>";
 
Post Reply

Return to “PHP & MySQL”