PHPackages                             green-elephpant/code-bench-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. green-elephpant/code-bench-laravel

ActiveLibrary[Testing &amp; Quality](/categories/testing)

green-elephpant/code-bench-laravel
==================================

A package to conveniently use CodeBench in your Laravel project

v1.1.0(9mo ago)09GPL-3.0-or-laterPHPPHP &gt;=7.4

Since Sep 8Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/green-elephpant/code-bench-laravel)[ Packagist](https://packagist.org/packages/green-elephpant/code-bench-laravel)[ RSS](/packages/green-elephpant-code-bench-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

 [![Green ElePHPant](./docs/images/green-elephpant-logo.svg)](./docs/images/green-elephpant-logo.svg)

Green ElePHPant - CodeBench Laravel
===================================

[](#green-elephpant---codebench-laravel)

The **Green ElePHPant** wants to help you to reduce the carbon emissions of your software.

One way of doing so is to optimize the performance. Less CPU, RAM and Storage means reduced energy consumption, fewer carbon emissions, and less hardware to be produced. And, last but not least, the users of your software will benefit from a faster application.

`GreenElephpant\CodeBenchLarvel` is a tiny package to conveniently include [CodeBench](https://github.com/green-elephpant/code-bench) into your Laravel project.

Key concept
-----------

[](#key-concept)

`GreenElephpant\CodeBench` is a simple helper to compare the performance of code blocks. This package configures `GreenElephpant\CodeBench` to directly use `Log::debug()`.

It provides helper functions like `codebench_start()` and `codebench_stop()` to measure the time and memory taken by a code block.

Installation
------------

[](#installation)

`composer require green-elephpant/code-bench-laravel --dev`

*Note:* we use `require-dev` here, since `GreenElephpant\CodeBench` should not be used in production code.

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

`codebench()` is a helper function to conveniently call the `GreenElephpant\CodeBench\CodeBench` class.

You can use it to compare the performance of two callbacks:

```
codebench([
    function () {
        // The first option we want to test
        date('D M d Y H:m:s');
    },
    function () {
        // The second option we want to test
        (new DateTime())->format('D M d Y H:m:s');
    }
]);
```

Please see the [CodeBench](https://github.com/green-elephpant/code-bench?tab=readme-ov-file#basic-usage) documentation on more information.

The results will be logged using Laravel's `Log::debug()` by default. See [Set Logger callable](https://github.com/green-elephpant/code-bench?tab=readme-ov-file#set-logger-callable) for more information.

### Measure the performance of a code block

[](#measure-the-performance-of-a-code-block)

You can use the `codebench_start()` and `codebench_stop()` functions to measure the performance of a code block.

```
codebench_start();

// Your code block here
for ($i = 0; $i < 1000; $i++) {
    expensive_function_call();
}

codebench_stop();
```

Also here, the results will be logged using Laravel's `Log::debug()` by default.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance58

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~170 days

Total

3

Last Release

275d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4761678d271eef1bc9fc3478994848dd54b6d77551e3c065b1b730b5badffb90?d=identicon)[carstenwindler](/maintainers/carstenwindler)

---

Top Contributors

[![carstenwindler](https://avatars.githubusercontent.com/u/5927645?v=4)](https://github.com/carstenwindler "carstenwindler (6 commits)")

---

Tags

laravelperformancebenchmarking

### Embed Badge

![Health badge](/badges/green-elephpant-code-bench-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/green-elephpant-code-bench-laravel/health.svg)](https://phpackages.com/packages/green-elephpant-code-bench-laravel)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[mpociot/laravel-test-factory-helper

Generate Laravel test factories from your existing models

933635.2k2](/packages/mpociot-laravel-test-factory-helper)[christophrumpel/missing-livewire-assertions

This package adds missing livewire test assertions.

149336.0k9](/packages/christophrumpel-missing-livewire-assertions)[davestewart/sketchpad

An innovative front-end environment for interactive Laravel development

29512.9k1](/packages/davestewart-sketchpad)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
