Wednesday, June 10, 2015

Get webpage loading time using PHP



Execution of server side scripting need to optimize in order to get the Optimized page loading time. In this case most of the Server Side Response typically not more than 2 to 30 seconds. In this case we need to find the Exact page loading time in PHP using the following Script.
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

function page_loading_time()
{
    list ($msec, $sec) = explode(' ', microtime());
    $microtime = (float)$msec + (float)$sec;
    return $microtime;
}

$start=page_loading_time();

usleep(100000);  // Delaying page output 0.1 second for testing purpose.

echo "
";
$end = page_loading_time();
// Print results.
echo 'Page Loading Time: ' . round($end - $start, 2) . ' seconds';   


?>
 

© 2014 4everTutorials. All rights resevered.

Back To Top