Jan 26, 2015

Find PHP bottleneck!

There are many ways, such as Xhprof. However, because I already had Xdebug I will use Xdebug to profile the app; and setup Xdebug seems easier than Xhprof.

1. First set these in .htaccess (or php.ini)

php_value xdebug.profiler_enable 1
php_value xdebug.profiler_output_dir "/var/xdebug/"

2. Make sure that /var/xdebug/ is writable by web app, or change it to your folder.

3. Run the request to benchmark.

4. Each request will result in a new file /var/xdebug/cachegrind.out.NNNN

5. To read these stats needs brew install qcachegrind on Mac OSX, or kcachegrind on Linux.
After installing them, run, eg: qcachegrind /var/xdebug/cachegrind.out.NNNN

6. Examine by clicking on "self" column; consider function that take longest time. Well from here we need to think about what caused these bottlenecks.


No comments:

Post a Comment

New comment