5

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

2 Answers 2

3

Have a look at the getrusage() function. It might provide you with something useful

Sign up to request clarification or add additional context in comments.

1 Comment

getrusage() is now supported on windows since PHP 7
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.