Blog

Load Time Script - PHP

Posted by Rajesh Kumar Yadav Blogs | PHP Apr 20, 2012
This blog shows how to find how long your site takes to load.
This one is a must for developers and system admins. You need to know how long your site takes to load. Nobody sticks around waiting for a site to load anymore – there's way too much content out there for that. Use this script to find out if your site is taking too long, and if it is, fix it..

PHP Code:

$starttime microtime();
$startarray explode(" "$starttime);
$starttime $startarray[1] + $startarray[0]; 

Insert this code snippet directly before the closing </body> tag of your document:

PHP Code:

$endtime microtime();
$endarray explode(" "$endtime);
$endtime $endarray[1] + $endarray[0];
$totaltime $endtime $starttime;
$totaltime round($totaltime,10);
echo 
"Seconds To Load: ";
printf ("%f\n"$totaltime); 

Example:

Seconds To Load: 0.000070
comments
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
More Blogs from this Blogger
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts