gpt4 book ai didi

php xhprof使用实例详解

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 24 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章php xhprof使用实例详解由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

xhprof php性能分析 。

1.clone xhprof 此版本为github第三方扩展 (php官房不支持 php 7) 。

https://github.com/longxinh/xhprof 。

2.extension 目录为扩展源码安状扩展即可 。

phpize && ./configure && make && make install 。

3.编辑php.ini 启用xhprof扩展 。

?
1
2
3
[xhprof]
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof ;性能分析数据文件存放位置 需要php用户有可写可读权限

4.对项目入口文件添加代码 。

?
1
2
3
4
5
6
7
8
9
10
11
xhprof_enable(xhprof_flags_no_builtins +
xhprof_flags_cpu +
      xhprof_flags_memory);
register_shutdown_function( function (){
$data = xhprof_disable(); 
   //xhprof_lib 在第一步git clone 后的文件夹里面
   include '/mnt/d/www/xhprof/xhprof_lib/utils/xhprof_lib.php' ;
   include '/mnt/d/www/xhprof/xhprof_lib/utils/xhprof_runs.php' ;
   $objxhprofrun = new xhprofruns_default();
   $objxhprofrun ->save_run( $data , "table" ); //生成数据文件后缀
});

5.nginx 或者 apache 创建 网占目录(apache为例) 。

?
1
2
3
4
5
6
7
8
9
10
11
<virtualhost *:80>
   servername xhprof.com
   ## xhprof/xhprof_html 在第一步git clone 后的文件夹里面
   documentroot "/mnt/d/www/xhprof/xhprof_html"
   directoryindex index.html index.php index.html
   <directory "/mnt/d/www/xhprof/xhprof_html" >
      options indexes followsymlinks
      allowoverride all
      require all granted
   </directory>
  </virtualhost>

6.访问  http://xhprof.com/ (上面虚拟主机配置的 本地域名需要host )显示每次程序运行生成的性能分析数据文件 点击可以打 开 。

php xhprof使用实例详解

php xhprof使用实例详解

7.如果想要查看性能图点击 view full callgraph (服务器需要安装 graphviz 库) 。

ubuntu 安装方法 (pro apt-get install graphviz) 。

8.显示效果图 。

php xhprof使用实例详解

总结 。

以上所述是小编给大家介绍的php xhprof使用实例详解 ,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我网站的支持! 。

如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

原文链接:https://segmentfault.com/a/1190000018856380 。

最后此篇关于php xhprof使用实例详解的文章就讲到这里了,如果你想了解更多关于php xhprof使用实例详解的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com