需要测试下 代码的性能,使用了 xhprof + xhgui
1. 下载xhprof,
这里下载吧 :https://github.com/longxinH/xhprof.git
2, 安装
cd xhprof/extension/
/usr/local/php/bin/phpize ./configure --with-php-config=/opt/php-7.0.14/bin/php-config --enable-xhprof
make&&make install
3.修改 php.ini 文件
php -i | grep php.ini
[xhprof]extension=xhprof.soxhprof.output_dir=/data/www/xhprof/save_output_dir //该目录自由定义即可,用来保存xhprof生成的源文件
重启php-fpm
kill -USR2 `cat /opt/php-7.0.14/var/run/php-fpm.pid`
//切换到下载的 xhprof 目录cp -r xhprof/xhprof_html ?ROOT_PATH/cp -r xhprof/xhprof_lib ROOT_PATH/
xhprof_enable(); //你需要分析的代码
$xhprof_data = xhprof_disable();
include_once ROOT_PATH.‘/xhprof_lib/utils/xhprof_lib.php‘;
include_once ROOT_PATH . ‘/xhprof_lib/utils/xhprof_runs.php‘;
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_test"); //将run_id保存起来或者随代码一起输出
yum install graphviz
查看结果
$host_url/xhpfrof_html/index.php?run=58d3b28b521f6&source=xhprof_test
php7下 xhprof安装与使用
原文地址:http://www.cnblogs.com/guixiaoming/p/7656227.html