PHP – Calculating execution time

January 25th, 2010 at 3:04 pm by Rick

Here is an easy way of calculating the time elapsed during some script execution in PHP, using microtime() :

1
2
3
4
5
$exec_start = microtime(true); // 'true' returns the seconds of type double

// ... do stuff

echo (microtime(true) - $exec_start) . ' seconds';

Comments are closed.