ohansyah/laravelbenchmark 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ohansyah/laravelbenchmark

最新稳定版本:v0.1.2

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

Latest Version Total Downloads License

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.

统计信息

  • 总下载量: 1.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固