百度统计 网站速度诊断,苏州企业网站制作开发,网上商城网站建设体会,2022做网站还能赚钱吗这篇文章主要介绍了关于PHP 7.1安装xhprof进行性能分析的介绍#xff0c;有着一定的参考价值#xff0c;现在分享给大家#xff0c;有需要的朋友可以参考一下安装扩展该 xhprof扩展版本是从 https://github.com/longxinH/xhprof 获取的(第三方的一个库#xff0c;官方版本不…这篇文章主要介绍了关于PHP 7.1安装xhprof进行性能分析的介绍有着一定的参考价值现在分享给大家有需要的朋友可以参考一下安装扩展该 xhprof扩展版本是从 https://github.com/longxinH/xhprof 获取的(第三方的一个库官方版本不支持php7)下载并编译xhprof扩展在web的html目录下操作git clone https://github.com/longxinH/xhprof编译扩展cd xhprof/extension/phpize./configuremakemake install修改php.ini配置[xhprof]extensionxhprof.so;xhprof.output_dir/tmp/xhprof其中 xhprof.output_dir 是 xhprof 的输出目录每次执行 xhprof 的 save_run 方法时都会生成一个 run_id.project_name.xhprof 文件。这个目录在哪里并不重要。注意此路径的权限要可读写否则文件无法生成成功重启 php-fpmsudo service php7.1-fpm restart添加测试代码xhprof_enable(XHPROF_FLAGS_CPU XHPROF_FLAGS_MEMORY);// 要检查性能的代码$xhprof_data xhprof_disable();include_once /var/www/html/xhprof/xhprof_lib/utils/xhprof_lib.php;include_once /var/www/html/xhprof/xhprof_lib/utils/xhprof_runs.php;$xhprof_runs new \XHProfRuns_Default();$run_id $xhprof_runs-save_run($xhprof_data, your_project);测试代码中要引入xhprof_lib.php和xhprof_runs.php两个文件查看生成报告需要访问xhprof/xhprof_html/index.php文件查看http://localhost/xhprof/xhprof_html/index.php?run5b35d3dfa8c29sourceyour_projectrun后的参数为$run_idsource参数为your_project配置的名字如果图表生成错误需要安装插件sudo apt-get install graphviz实际演示代码function test1(){for($i0;$i10;$i){echo aaa.$i.;}}// start profilingxhprof_enable();test1();// stop profiler$xhprof_data xhprof_disable();// display raw xhprof data for the profiler runprint_r($xhprof_data);include_once xhprof_lib.php;include_once xhprof_runs.php;// save raw data for this profiler run using default// implementation of iXHProfRuns.$xhprof_runs new XHProfRuns_Default();// save the run under a namespace xhprof_test$run_id $xhprof_runs-save_run($xhprof_data, xhprof_test);echo ---------------\n.Assuming you have set up the http based UI for \n.XHProf at some address, you can view run at \n.http:///index.php?run$run_idsourcexhprof_test\n.---------------\n;以上就是本文的全部内容希望对大家的学习有所帮助更多相关内容请关注PHP中文网相关推荐