mtolhuys/laravel-request-benchmark

Configurable middleware measuring your request's time and memory usage

1.1.1 2019-08-04 20:03 UTC

This package is auto-updated.

Last update: 2024-05-05 06:18:44 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

This package comes with a benchmark middleware which, if included, will measure your requests time and memory usage.

Installation

You can install the package via composer:

composer require mtolhuys/laravel-request-benchmark

Usage

Add the 'benchmark' middleware to the routes you want to measure f.e.:

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

// Or

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

Out of the box this will create debug log entries f.e.:

[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)  

As well as a overview page on route /request-benchmark containing a table showing the results stored in request-benchmark.json file.

This behavior is configurable with the included request-benchmark config file. Run php artisan vendor:publish --provider="Mtolhuys\LaravelRequestBenchmark\LaravelRequestBenchmarkServiceProvider" if you don't see it in your config/ folder.

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
];

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mtolhuys@hotmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.