1 下载xhprof
https://pecl.php.net/package/xhprof
2 复制php_xhprof.dll到php/ext目录下
3 配置xhprof
[xhprof] extension=xhprof xhprof.output_dir=D:\program\phpstudy_pro\Extensions\xhprof
4 重启nginx
5 下载xhprof库文件
https://github.com/phacility/xhprof
6 将下载好的文件下的xhprof_html目录配置xhprof.xyz的站点目录
7 项目中引入xhprof库文件
8 安装graphviz画图工具
9 性能分析
\xhprof_enable(XHPROF_FLAGS_MEMORY + XHPROF_FLAGS_CPU + XHPROF_FLAGS_NO_BUILTINS);
//
//TODO:项目代码
//
$xhprof_data = \xhprof_disable();
include_once Env::get('extend_path') . '/xhprof_lib/utils/xhprof_lib.php';
include_once Env::get('extend_path') . '/xhprof_lib/utils/xhprof_runs.php';
$xhprof_runs = new \XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, 'test');
10 打开xhprof.xyz查看分析结果