Profiling

An oft-overlooked feature of IDEs is built-in profiling support. Profiling is the technique of studying the execution of your script, and reporting back how much time was spent in each function - this is absolutely crucial if you are trying to squeeze every last drop of performance out of your code. The 80/20 rule states that 80% of your program's execution time will be spent in just 20% of your code - do not spend your time optimising the 80% of your code that takes up just 20% of your execution time, because it is just not worth the effort.

Profiling helps immensely by providing a clear cut list of results: function A took up 60% of execution time, function B took up 2%. If you do not have profiling, you are as likely to try to optimise function B as you are function A, because you just might not realise how much more important function A is to your performance.

 

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Popular IDEs >>

Previous chapter: Interactive debugging

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.