xdebug+webgrind

xdebug 安装配置

  1. brew install php(对应的版本)xdebug
  2. 配置php.ini信息

    [xdebug]

    ;基本调试配置

    xdebug.auto_trace = on

    xdebug.collect_params = on

    xdebug.collect_return = on

    xdebug.profiler_enable = on

    xdebug.profiler_output_dir ="/tmp/xdebug_profilers"

    xdebug.trace_output_dir = "/tmp/xdebug_traces"

    ;远程调试设置

    #xdebug.remote_enable = on

    #xdebug.remote_host = localhost

    #xdebug.remote_port = 9010

    #xdebug.remote_autostart = on

  3. A、涉及的配置

    xdebug.profiler_enable

    //该配置默认为0,为开启,设置为非0之后,即开启profiler功能

    xdebug.profiler_output_dir

    //该配置为上面开启之后,存放生成分析文件的位置,需要保证位置可写入,默认/tmp

    xdebug.profiler_enable_trigger

    //如果开启该选项,则在每次请求中如果GET/POST或cookie中包含//XDEBUG_PROFILE变量名,则才会生成性能报告文件(前提是必须关闭

    //xdebug.profiler_enable选项,否则该选项不起作用)。

    xdebug.profiler_output_name

    //可以使用该配置修改生成的分析文件,默认cachegrind.out.%p

    NOTE:

    建议使用xdebug.profiler_enable_trigger替代xdebug.profiler_enable

  4. 重启apache OR nginx php

 

由于生产的文件不是直接可以查看的 所以我们需要用可视化的工具来查看mac用以下   可视化工具WebGrind下载与配置

WebGrind可以在这里下载:https://github.com/jokkedk/webgrind

  1. webgrind v1.1以后 的版本增加了 Show Call Graph 按钮,依赖 python 和 dot 命令, 类似 xhprof 的 View Full Callgraph 绘制程序调用流程图功能,相对于 xhprof 较简洁。 更多 xhprof 信息请查看 使用 XHProf 分析你的 PHP 程序。

    配置 webgrind 的绘制流程图功能,查看 python 和 dot 命令位置 which python which dot,编辑 webgrind/config.php,将 $pythonExecutable = '你的python路径' 和 $dotExecutable = '你的dot路径' 替换为刚查到相应路径。

  2. 以上自己安装brew install python & graphviz
  3. webgrind config 配置

    static $storageDir = '/tmp/storage';
    static $profilerDir = '/tmp/xdebug';
    static $pythonExecutable = '/usr/bin/python';
    static $dotExecutable = '/usr/local/bin/dot';

  4. 最后就可以访问你的网站地址http://localhost:8080/ 接着在访问http://localhost:8080/webgrind/index.php  就能看到你的性能咯

 

posted @ 2017-06-01 12:08  壊壊在梦游  阅读(656)  评论(0编辑  收藏  举报