PHP 7.1安裝xhprof進行效能分析的介紹
這篇文章主要介紹了關於PHP 7.1安裝xhprof進行效能分析的介紹,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下
##安裝擴充功能該xhprof擴充版本是從https://github.com/longxinH/xhprof 取得的(第三方的一個函式庫,官方版本不支援php7)
在web的html目錄下操作:
git clone https://github.com/longxinH/xhprof
編譯擴充功能
cd xhprof/extension/phpize ./configure makemake install
[xhprof] extension=xhprof.so; xhprof.output_dir=/tmp/xhprof
重啟php-fpmsudo service php7.1-fpm restart
<?php
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?run=5b35d3dfa8c29&source=your_projectrun後的參數為$run_id,source參數為your_project的名字
如果圖表產生錯誤,需要安裝外掛程式:
<?php function test1(){ for($i=0;$i<10;$i++){ echo 'aaa'.$i.'<br>'; } }// 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://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_test\n". "---------------\n";
以上是PHP 7.1安裝xhprof進行效能分析的介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

JWT是一種基於JSON的開放標準,用於在各方之間安全地傳輸信息,主要用於身份驗證和信息交換。 1.JWT由Header、Payload和Signature三部分組成。 2.JWT的工作原理包括生成JWT、驗證JWT和解析Payload三個步驟。 3.在PHP中使用JWT進行身份驗證時,可以生成和驗證JWT,並在高級用法中包含用戶角色和權限信息。 4.常見錯誤包括簽名驗證失敗、令牌過期和Payload過大,調試技巧包括使用調試工具和日誌記錄。 5.性能優化和最佳實踐包括使用合適的簽名算法、合理設置有效期、

文章討論了PHP 5.3中介紹的PHP中的晚期靜態結合(LSB),允許靜態方法的運行時間分辨率調用以更靈活的繼承。 LSB的實用應用和潛在的觸摸

SOLID原則在PHP開發中的應用包括:1.單一職責原則(SRP):每個類只負責一個功能。 2.開閉原則(OCP):通過擴展而非修改實現變化。 3.里氏替換原則(LSP):子類可替換基類而不影響程序正確性。 4.接口隔離原則(ISP):使用細粒度接口避免依賴不使用的方法。 5.依賴倒置原則(DIP):高低層次模塊都依賴於抽象,通過依賴注入實現。

使用PHP的cURL庫發送JSON數據在PHP開發中,經常需要與外部API進行交互,其中一種常見的方式是使用cURL庫發送POST�...

如何在系統重啟後自動設置unixsocket的權限每次系統重啟後,我們都需要執行以下命令來修改unixsocket的權限:sudo...
