php----------php安装xhprof扩展和简单使用

一、下载源码包 https://github.com/longxinH/xhprof  (wget https://github.com/longxinH/xhprof/archive/master.zip)    下面截图那个是官网的,已经没有维护了,不行了。php

  

二、编译html

  

  

三、./configure --with-php-config=/usr/local/php/bin/php-confignginx

  

四、make && make installlaravel

  

五、而后在 /etc/php.ini里面增长 extension=xhprof.so  保存退出。完成,执行php -m能够查看一下。git

六、将以前下载的扩展包,移动到网站根目录下github

  

  而后直接访问 http://192.168.18.160/xhprof/examples/sample.php网站

  

  拿到红线画的之后,直接访问 http://192.168.18.160/xhprof/xhprof_html/index.php?run=5ac86cc0cec09&source=xhprof_foo
spa


  而后安装 yum install -y graphviz3d

  点击箭头指的地方,就能够看到图形界面code

  

  红色表明运行时间长的代码块

  http://192.168.18.160/xhprof/xhprof_html/index.php  能够查看历史检测的记录

  

七、正式项目中,在入口文件加入

开头 : xhprof_enable();

结尾:

  $data = xhprof_disable();  include_once "/usr/local/nginx/html/laravel/public/xhprof/xhprof_lib/utils/xhprof_lib.php";  include_once "/usr/local/nginx/html/laravel/public/xhprof/xhprof_lib/utils/xhprof_runs.php";  $aa = new XHProfRuns_Default();  $aa->save_run($data,"test");

相关文章
相关标签/搜索