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:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With