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

v1.0.4
版本
2023-11-14
版本更新時(shí)間
165
安裝
4
star
簡(jiǎn)介
aaron-dev/xhprof-webman是一款適配webman的代碼性能分析插件。
主要對(duì)舊版且無(wú)法使用的xhprof做優(yōu)化調(diào)整,用于適配webman,安裝簡(jiǎn)單快捷。
開(kāi)發(fā)者可以通過(guò)瀏覽器快速訪問(wèn)性能分析報(bào)告,排查代碼性能問(wèn)題。
安裝
php要安裝xhprof擴(kuò)展
在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)超過(guò)多少秒的請(qǐng)求 默認(rèn)0記錄所有 'log_num' => 1000, //僅記錄最近的多少次請(qǐng)求(最大值有待觀察,看日志、查看響應(yīng)時(shí)間) 默認(rèn)1000 'view_wtred' => 3, //列表耗時(shí)超過(guò)多少秒標(biāo)紅 默認(rèn)3s 'ignore_url_arr' => ["/test"], //忽略URL配置
-
然后重啟服務(wù)就可以訪問(wèn)了。