Monday, March 5, 2012

Page Loading Time 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.


Find Page Loading Time PHP
<?php
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 "<br />";
$end = page_loading_time();
// Print results.
echo 'Page Loading Time: <b>' . round($end - $start, 2) . '</b> seconds';   
?>

No comments:

Post a Comment