Package Data | |
---|---|
Maintainer Username: | ohansyah |
Maintainer Contact: | ohansyah@weekendinc.com (ohansyah) |
Package Create Date: | 2023-12-02 |
Package Last Update: | 2023-12-04 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-11 15:27:14 |
Package Statistics | |
---|---|
Total Downloads: | 47 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
The Laravel Benchmark package provides a simple and convenient way to benchmark certain parts of your Laravel application. This can be useful when you need to measure the performance of specific code snippets or functions.
This package is inspired by the Laravel 9.x helper benchmarking feature, as discussed in Laravel Documentation and contributed by Nuno Maduro. However, this package is specifically designed to be compatible with older PHP versions and Laravel legacy projects.
You can install the package via Composer:
composer require ohansyah/laravelbenchmark
<?php
use App\Models\User;
use Illuminate\Support\Benchmark;
Benchmark::dd(
function () { range(1, 1000000); }
);
// 11.415ms
Benchmark::dd([
function () { range(1, 1000000); },
function () { User::count(); }
]);
/*
array:2 [
0 => "10.259ms"
1 => "111.418ms"
]
*/
By default, the given callbacks will be executed once (one iteration), and their duration will be displayed in the browser / console.
To invoke a callback more than once, you may specify the number of iterations that the callback should be invoked as the second argument to the method. When executing a callback more than once, the Benchmark class will return the average amount of milliseconds it took to execute the callback across all iterations
Benchmark::dd(
function () { range(1, 1000000); }, 5
);
// 10.041ms
The Laravel Benchmark package is open-sourced software licensed under the MIT License.