Calculate PHP Load time

Have you ever load a page with your Broadband just like using a Dial Up connection? Sometimes, it is not because of the ISP connection problem but it’s just because the scripting that not fully optimized.

If you design PHP script, it’s good practice to benchmark your pages to see the if you could optimize the pages.

The following script let you understand how fast your script loaded.

Put the following script to the most top of your PHP script just after the php tag.

$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$loadstart = $m_time;

Then place this script to the bottom of the script to calculate the time.

$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>";