开发者

How to measure PHP script execution in CPU cycles?

开发者 https://www.devze.com 2023-01-04 22:17 出处:网络
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

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:)

0

精彩评论

暂无评论...
验证码 换一张
取 消