Sunday, August 14, 2011

Function to Calculate PHP Script Execution Time

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

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

$start=process_microtime ();

// Your PHP Code Block and Process

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


No comments:

Post a Comment