Page Generated in Seconds

By Will26 on Jul 16, 2005

Tells you how many seconds page loaded in...

sample: Page loaded in 0.001 seconds.

/* This part of the script goes at the top of your page */
<?php

$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];

?>

/* This part of the script goes where you want load time to be displayed */
<?php

$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
printf('Page loaded in %.3f seconds.', $totaltime);

?>

Comments

Sign in to comment.
Hans Henrik   -  Feb 15, 2012

just; "Page loaded" should be "Page generated";
we dont know the speed of the connection, or the server's buffer settings, bandwidth trottling, etc; we dont know how long it took to load the page, just how long it took for php to generate the page.

also digibluez: your code dont work at all.. it never calculates how long it took to generate the page.

 Respond  
digibluez   -  Sep 02, 2005

HERES A BETTER and shorter code of this.
Put it just in the footer and it shows the time with 0.00s not 000.000blabal

<?php $load = microtime();print (number_format($load,2));?>

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.