xdebug进行性能分析

stingfire 2012-05-16

PHP昨天网站出现了性能问题,使用了xdebug进行性能分析,效果不错。

xdebug会生产分析日志,ubuntu下面可以用kcachegrind对日志进行分析。

安装:sudo apt-get install kcachegrind

windows下面类似的分析工具是:WinCacheGrind

xdebug的配置:

[xdebug]

zend_extension=/usr/lib/php5/xdebug.so

xdebug.profiler_enable=0

xdebug.auto_trace = 1

xdebug.profiler_enable_trigger = 1

xdebug.profiler_output_dir=/data/www/website/xdebug/

其中profiler_enable不要设置成1,不然所有的脚本运行都会写日志,profiler_enable_trigger =1 是在网址后面带XDEBUG_PROFILE参数,才会生成日志。(例:http://path/to/index.php?XDEBUG_PROFILE)

相关推荐