PHP性能分析工具xdebug+qcachegrind

先安裝xdebug工具php

pecl install xdebug

修改php.ini配置工具

[xdebug] zend_extension="xdebug.so"性能

# profiler功能的開關,默認值0,若是設爲1,則每次請求都會生成一個性能報告文件。.net

# xdebug.profiler_enable=0命令行

# 默認值是0,若是設爲1 則當咱們的請求中包含 XDEBUG_PROFILE 參數時纔會生成性能報告文件debug

xdebug.profiler_enable_trigger=1code

# 分析文件保存目錄, 默認是 /var/tmp xdebug.profiler_output_dir="/var/tmp/xdebug"blog

請求參數加上XDEBUG_PROFILE纔會生成分析文件, 會生成在這裏 /var/tmp/xdebugit

http://127.0.0.1/phpinfo.php?XDEBUG_PROFILEio

安裝qcachegrind 

brew install qcachegrind --with-graphviz

 

在命令行裏使用 qcachegrind 打開它,而後經過它打開要分析的文件

也能夠在命令後直接跟要分析的文件

qcachegrind

/var/tmp/xdebug/cachegrind.out.38595

參考: http://yzone.net/blog/151 https://stackoverflow.com/questions/4473185/do-you-have-kcachegrind-like-profiling-tools-for-mac http://stackoverflow.org.cn/front/ask/view?ask_id=340042

相關文章
相關標籤/搜索