PHP Profiling

July 20th, 2009 Posted in Open Source

A number of factors can affect the performance of a PHP Web application, including Web server configuration, database performance, data structure, the application design and the implementation of the application.Usually we will take care of the first items, and now we want to iron out bottlenecks in our application implementation, that is, in the actual code. But how do you find the bottlenecks in the first place?

The answer is a technique known as performance profiling. Performance profiling runs your code in a controlled environment and returns a report listing such statistics as time spent within each function, how long each database query takes and how much memory has been used.

Using performance profiling on your code, you can see where you may be wasting time with slow database queries or inefficient code. Using this information we can tune PHP and SQL where it needs it most. No more guessing what’s going on internally performance profiling gives you hard figures.

Profiling Tools

A number of different tools have been developed to help with PHP performance profiling, including Benchmark (a PEAR project), DBG, Xdebug and Advanced PHP Debugger (another PEAR project).

Leave a Reply