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

Published by

Mick Genie

Mick Genie is the founder of and working at ExaBytes Network Sdn Bhd and WPWebHost web host company. He is expertise in Windows and Linux environment especially web hosting related information, tips and trick as well as the IT Information.

One thought on “Calculate PHP Load time”

  1. Thanks for the script, I actually tried a bunch of different ones but obviously the codes authors didn’t test them. I can confirm that this tutorial actually works with php 5.3.

Comments are closed.