Function to Calculate PHP Script Execution Time

Sunday, August 14, 2011

PHP Script execution time response is important for quick responsive script, we can able to measure our script execution time with the following script. based on this we can optimize our Script Efficiency








<?php
function process_microtime ()
{
    list ($msec, $sec) = explode(' ', microtime());
    $microtime = (float)$msec + (float)$sec;
    return $microtime;
}

$start=process_microtime ();

// Your PHP Code Block and Process
sleep(1);

echo "<br/>";
$end = process_microtime();
// Print results.
echo 'Script Execution Time: <b>' . round($end - $start, 3) . '</b> seconds';   

?>

No comments:

Post a Comment