PHP – Estimate Page Loaded Time

Sometime you need to estimate your page loaded time or the query/code loaded time, so the given
example helps you to find out the loaded time of you code:

Code Example: Download Example

Put the following code at the very top of the page or top of any query/code.

<?php
$mtime = microtime(); 
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime; 
?>

// you all page contents here or query/code
code...
code...

and then 

Put the following code at the bottom of the page or bottom of any query/code

<?php
$mtime = microtime();    
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime); 

echo "Your page was created in $totaltime";
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *