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(1y ago)09GPL-3.0-or-laterPHPPHP &gt;=7.4

Since Sep 8Pushed 1y 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 2w 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

27

—

LowBetter than 46% of packages

Maintenance50

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

367d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5927645?v=4)[Carsten Windler](/maintainers/carstenwindler)[@carstenwindler](https://github.com/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

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[calebdw/larastan

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

16132.2k4](/packages/calebdw-larastan)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)

PHPackages © 2026

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