xhprof性能分析插件,可以在web瀏覽器查看。

v1.0.4
版本
2023-11-14
版本更新時間
162
安裝
4
star
簡介
aaron-dev/xhprof-webman是一款適配webman的代碼性能分析插件。
主要對舊版且無法使用的xhprof做優(yōu)化調(diào)整,用于適配webman,安裝簡單快捷。
開發(fā)者可以通過瀏覽器快速訪問性能分析報告,排查代碼性能問題。
安裝
php要安裝xhprof擴展
在php.ini中增加配置
[xhprof]
extension=xhprof.so;
xhprof.output_dir=/tmp/xhprof;
Use Composer:
composer require aaron-dev/xhprof-webman
配置
-
config增加全局中間件
'' => [ Aaron\Xhprof\Webman\XhprofMiddleware::class, ]
-
創(chuàng)建控制器,復(fù)制下面代碼
<?php namespace app\controller; use support\Request; use Aaron\Xhprof\Webman\Xhprof; class TestController { public function index(Request $request) { return Xhprof::index(); } }
-
路由增加以下代碼
Route::get('/test', ['app\controller\TestController','index']);
-
基礎(chǔ)配置在config/plugin/aaron-dev/xhprof/xhprof.php中
'enable' => true, 'time_limit' => 0, //僅記錄響應(yīng)超過多少秒的請求 默認0記錄所有 'log_num' => 1000, //僅記錄最近的多少次請求(最大值有待觀察,看日志、查看響應(yīng)時間) 默認1000 'view_wtred' => 3, //列表耗時超過多少秒標紅 默認3s 'ignore_url_arr' => ["/test"], //忽略URL配置
-
然后重啟服務(wù)就可以訪問了。