How can I measure my PHP script execution in CPU cycles? I do not need execution time, because if script connects to db开发者_运维技巧 or to external API , its waiting and do not consume CPU resources.
EDIT: PHP<5.3, Windows
Have a look at the getrusage() function. It might provide you with something useful
Try using a profiler. ( http://xdebug.org/docs/profiler )
Measuring code cycles may vary because the zend engine may or may not optimized the opcodes, the way the zend engine was compiled may lead to it doing some operations faster, etc.
Also, the time it takes to connect to the DB may be "handled" by doing some mock classes (http://en.wikipedia.org/wiki/Mock_object), but in a real application, the time it takes to connect to the DB is important, because the user perceives the whole webpage as being slow, not the SQL server being slow:)
精彩评论