mtolhuys/laravel-request-benchmark

可配置的中间件,用于测量请求的时间和内存使用情况

1.1.1 2019-08-04 20:03 UTC

This package is auto-updated.

Last update: 2024-09-05 07:00:45 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

本包包含一个基准测试中间件,如果您将其包含在内,则可以测量请求的时间和内存使用情况。

安装

您可以通过composer安装此包

composer require mtolhuys/laravel-request-benchmark

使用方法

'benchmark'中间件添加到您想要测量的路由中,例如。

Route::group(['middleware' => ['foo', 'bar', 'benchmark']], function() {  
    // benchmarked routes  
});

// Or

Route::get('/', 'IndexController@index')->middleware('benchmark');

默认情况下,这将创建调试日志条目,例如。

[yyyy-mm-dd hh:mm:ss] local.DEBUG: request-benchmark: GET[http://localhost]
Time: 1.05ms
Pre memory usage 3169Kb
Post memory usage 3296Kb (127Kb)  

此外,在路由/request-benchmark上创建一个概览页面,其中包含一个表格,显示存储在request-benchmark.json文件中的结果。

此行为可以通过包含的request-benchmark配置文件进行配置。如果您在config/文件夹中看不到它,请运行php artisan vendor:publish --provider="Mtolhuys\LaravelRequestBenchmark\LaravelRequestBenchmarkServiceProvider"

return [
    'enabled' => true, // set to false to globally stop benchmark
    'log' => true, // set to false to stop creating log entries
    'storage_path' => null, // if specified it will create a request-benchmark.json containing all data
];

测试

composer test

变更日志

有关最近更改的更多信息,请参阅变更日志

贡献

有关详细信息,请参阅贡献指南

安全

如果您发现任何安全相关的问题,请通过mtolhuys@hotmail.com发送电子邮件,而不是使用问题跟踪器。

鸣谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件