Thursday, 4 December 2014

How to find execution time for a script in PHP

if your are a PHP dev and you execute php scripts to test time taken, the following code can help you

microtime — Return current Unix timestamp with microseconds

//Start time
$time_start = microtime(true);

// Sleep for 1 sec

//Execution of your script

//End time
$time_end = microtime(true);

//Time taken
$time = $time_end - $time_start;

echo "Time taken is $time seconds\n";


Hope this will be useful in your application