Timing Each Element of a Script
I have been working on this script for a long time, but the code takes about 300ms to execute, which is a little longer than I am happy with, so I was wondering if anyone knew how to time the script, but how long each event takes.
I was thinking of putting a timer function before and after each line, but given the si开发者_运维百科ze of the code, this would take forever.
If anyone knows of any tools, then that would be great.
N.B. A while ago I remember reading something on php.net about a PHP call that would run another function every so many procedures.
Use a tool to profile your code.
Take a look at the xdebug extension's profiling features.
This will allow you to visualize the time taken by each function, how many times it's called, its callers and callees, etc.
I think what you read about was related to ticks: http://www.freeopenbook.com/phpcookbook/phpckbk-chp-8-sect-26.html
精彩评论