ohansyah/laravelbenchmark
Composer 安装命令:
composer require ohansyah/laravelbenchmark
包简介
Measure the number of milliseconds it takes for the given callbacks to complete. This code is from the laravel 9.x helper benchmarking (https://laravel.com/docs/9.x/helpers#benchmarking) PR by by Nuno Maduro https://github.com/laravel/framework/pull/44252. Rewrite intend to run it on old php and lar
README 文档
README
Introduction
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.
Installation
You can install the package via Composer:
composer require ohansyah/laravelbenchmark
Usage
<?php
use App\Models\User;
use Ohansyah\LaravelBenchmark\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
License
The Laravel Benchmark package is open-sourced software licensed under the MIT License.
ohansyah/laravelbenchmark 适用场景与选型建议
ohansyah/laravelbenchmark 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debugging」 「benchmarking」 「laravel」 「slim」 「Devtools」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ohansyah/laravelbenchmark 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ohansyah/laravelbenchmark 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ohansyah/laravelbenchmark 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The official Kohana benchmarking module
Simple class for logging time and memory usage of stuff
A PHP package that takes a snapshot of your application and allows you to retrieve it later to help with debugging.
Laravel Database Query Logger and debug helper.
A simple helper class for Server Timing. Easily profile your code's execution time and send it to the client via the Server-Timing header.
A PHP security linter to detect insecure functions like var_dump, print_r, and other dangerous functions in your codebase
统计信息
- 总下载量: 1.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-02