先安装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