PHP must track the amount of CPU time a particular script has used in order to enforce the max_execution_time limit.
Is there a way to get access to this inside of the script? I'd like to include some logging with my tests about how much CPU was burnt in the actual PHP (the time is not incremented when the script is sitting and waiting for the database).
I am using a Linux box.
Shorter version of talal7860's answer
As pointed out, this is 'wallclock time' not 'cpu time'
The easiest way:
I think you should look at xdebug. The profiling options will give you a head start toward knowing many process related items.
http://www.xdebug.org/
As an alternative you can just put this line in your code blocks and check php logs, for really slow functions it's pretty useful:
For serious debugging use XDebug + Cachegrind, see https://blog.nexcess.net/2011/01/29/diagnosing-slow-php-execution-with-xdebug-and-kcachegrind/
Gringod at developerfusion.com gives this good answer:
From (http://www.developerfusion.com/code/2058/determine-execution-time-in-php/)
Further expanding on Hamid's answer, I wrote a helper class that can be started and stopped repeatedly (for profiling inside a loop).