aaron-dev / xhprof-webman
aaron-dev/xhprof-webman是一款兼容webman的代码性能分析插件。主要优化和调整旧版且无法使用的xhprof,以适应webman,使安装变得简单快捷。开发者可以通过浏览器快速访问性能分析报告,以便排查代码性能问题。
v1.0.4
2023-11-14 05:50 UTC
Requires
- php: >=7.2
- ext-xhprof: *
- illuminate/redis: *
- monolog/monolog: *
- workerman/webman: *
README
aaron-dev/xhprof-webman是一款适配webman的代码性能分析插件。 主要对旧版且无法使用的xhprof做优化调整,用于适配webman,安装简单快捷。 开发者可以通过浏览器快速访问性能分析报告,排查代码性能问题。
作者博客
安装
要安装xhprof扩展,需要在php.ini中增加配置
[xhprof]
extension=xhprof.so;
xhprof.output_dir=/tmp/xhprof;
使用Composer
composer require aaron-dev/xhprof-webman
配置
- 在config中增加全局中间件
'' => [
Aaron\Xhprof\Webman\XhprofMiddleware::class,
]
- 创建控制器,复制以下代码
<?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']);
- 基础配置位于config/plugin/aaron-dev/xhprof/xhprof.php中
'enable' => true,
'time_limit' => 0, //仅记录响应超过多少秒的请求 默认0记录所有
'log_num' => 1000, //仅记录最近的多少次请求(最大值有待观察,看日志、查看响应时间) 默认1000
'view_wtred' => 3, //列表耗时超过多少秒标红 默认3s
'ignore_url_arr' => ["/test"], //忽略URL配置