I’ve included a simple example of this below:
<?php // Place this at the very top of script $start = microtime(TRUE); // // The body of script goes here with lots of wonderful code. // // Place this at the very bottom of script $finish = microtime(TRUE); // Subtract the start time from the end time to get our difference in seconds $totaltime = $finish - $start; echo "This script took ".$totaltime." seconds to run";
The code above uses the function microtime(). This returns the amount of time, including microseconds, since the unix epoch. By adding ‘TRUE’ as a parameter we get the number returned in seconds to the nearest microsecond.
REFERENCES
http://biostall.com/getting-the-time-a-php-script-takes-to-execute