php----------php安裝xhprof擴展和簡單使用


1、下載源碼包 https://github.com/longxinH/xhprof  (wget https://github.com/longxinH/xhprof/archive/master.zip)    下面截圖那個是官網的,已經沒有維護了,不行了。

  

2、編譯

  

  

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

  

4、make && make install

  

5、然后在 /etc/php.ini里面增加 extension=xhprof.so  保存退出。完成,執行php -m可以查看一下。

6、將之前下載的擴展包,移動到網站根目錄下

  

  然后直接訪問 http://192.168.18.160/xhprof/examples/sample.php

  

  拿到紅線畫的以后,直接訪問 http://192.168.18.160/xhprof/xhprof_html/index.php?run=5ac86cc0cec09&source=xhprof_foo


  然后安裝 yum install -y graphviz

  點擊箭頭指的地方,就可以看到圖形界面

  

  紅色代表運行時間長的代碼塊

  http://192.168.18.160/xhprof/xhprof_html/index.php  可以查看歷史檢測的記錄

  

7、正式項目中,在入口文件加入

開頭 : 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");


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM