PHPackages                             janiaje/benchmark - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. janiaje/benchmark

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

janiaje/benchmark
=================

Benchmark package.

v2.0.1(2y ago)1688.5k↓51.8%2MITPHPPHP &gt;=5.6

Since Feb 4Pushed 2y ago2 watchersCompare

[ Source](https://github.com/Janiaje/laravel-benchmark)[ Packagist](https://packagist.org/packages/janiaje/benchmark)[ GitHub Sponsors](https://github.com/Janiaje)[ RSS](/packages/janiaje-benchmark/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

Laravel-Benchmark
=================

[](#laravel-benchmark)

Adds a Benchmark helper to your project, to get

- exact time
- elapsed time
- RAM usage
- queries ran by Eloquent

between checkpoints.

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

[](#installation)

```
composer require janiaje/benchmark
```

> If Laravel version &lt; 5.5, you have to manually include the following line in your config/app.php:

```
Janiaje\Benchmark\Provider::class,
```

Usage (basics)
--------------

[](#usage-basics)

### Use the 'benchmark()' helper to easily access to the Benchmark class

[](#use-the-benchmark-helper-to-easily-access-to-the-benchmark-class)

```
benchmark()
```

### Add checkpoints:

[](#add-checkpoints)

```
benchmark()->checkpoint();
```

### Get the elapsed time between the first and the last checkpoint

[](#get-the-elapsed-time-between-the-first-and-the-last-checkpoint)

```
$elapsedTime = benchmark()->getElapsedTime();
```

### Get the maximum amount RAM (in bytes) allocated by PHP in the checkpoints

[](#get-the-maximum-amount-ram-in-bytes-allocated-by-php-in-the-checkpoints)

```
$ramUsage = benchmark()->getPeakRamUsage();
```

### Get the checkpoints

[](#get-the-checkpoints)

```
$checkpoints = benchmark()->getCheckpoints();
```

### Dump the checkpoints

[](#dump-the-checkpoints)

```
benchmark()->dump();
```

### DD the checkpoints:

[](#dd-the-checkpoints)

```
benchmark()->dd();
```

### Set the output format for the checkpoints:

[](#set-the-output-format-for-the-checkpoints)

```
benchmark()->setOutputFormat(ArrayFormat::class);
benchmark()->setOutputFormat(JsonFormat::class);
```

The 2 options mentioned above are available by default. You can override them or make your own, but make sure it implements the `\Janiaje\Benchmark\OutputFormats\OutputFormat` interface.

Example of `ArrayFormat::class` output:

```
Collection {#275 ▼
  #items: array:2 [▼
    0 => array:6 [▼
      "id" => "#1"
      "name" => null
      "group" => null
      "time" => Carbon @1521101210 {#272 ▶}
      "timeDifference" => null
      "ram" => 6291456
      "queries" => []
    ]
    1 => array:6 [▼
      "id" => "#2"
      "name" => null
      "group" => null
      "time" => Carbon @1521101211 {#270 ▶}
      "timeDifference" => DateInterval {#277 ▶}
      "ram" => 6291456
      "queries" => array:1 [▼
        0 => {#279 ▼
          +"query": "SELECT * FROM users WHERE email = ?"
          +"bindings": array:1 [▼
            0 => "janiaje@gmail.com"
          ]
          +"time": 1.15
        }
      ]
    ]
  ]
}

```

Usage (additional options)
--------------------------

[](#usage-additional-options)

### Naming checkpoints

[](#naming-checkpoints)

This name will show up in the results so it will be easier to find a specific checkpoint.

```
benchmark()->checkpoint("After expensive calculation");
```

```
    1 => array:6 [▼
      "id" => "#2"
      "name" => "After expensive calculation"
      "group" => null
      "time" => Carbon @1521101211 {#270 ▶}

```

### Grouping checkpoints

[](#grouping-checkpoints)

Creating a checkpoint with a group:

```
benchmark()->checkpointWithGroup("File generation");
```

This group will show up in the results:

```
    1 => array:6 [▼
      "id" => "#2"
      "name" => "After expensive calculation"
      "group" => "File generation"
      "time" => Carbon @1521101211 {#270 ▶}

```

You can filter the results by groups:

```
benchmark()->getCheckpointsByGroup("File generation");
```

### Deleting checkpoints

[](#deleting-checkpoints)

Delete all checkpoints:

```
benchmark()->deleteAllCheckpoints();
```

Delete checkoints by group:

```
benchmark()->deleteCheckpoints("File generation");
```

Delete checkoints by id:

```
$checkpoint = benchmark()->checkpoint();
benchmark()->deleteCheckpoint($checkpoint->getId();
```

If you dont want to delete them, you can always create your own `Benchmark` instances and collect everythign sepearately:

```
$benchmark1 = new Benchmark;
$benchmark1->checkpoint();
$benchmark1->getAllCheckpoints();

$benchmark2 = new Benchmark;
$benchmark2->checkpoint();
$benchmark2->getAllCheckpoints();
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~515 days

Total

5

Last Release

985d ago

Major Versions

v1.0.2 → v2.0.02023-04-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/73ff0bb92df8e68d78564ee5e7df08d2c8db0151d2595a214866d861cfb778b9?d=identicon)[janiaje](/maintainers/janiaje)

---

Top Contributors

[![Janiaje](https://avatars.githubusercontent.com/u/25385437?v=4)](https://github.com/Janiaje "Janiaje (44 commits)")[![miladganjali](https://avatars.githubusercontent.com/u/8298544?v=4)](https://github.com/miladganjali "miladganjali (1 commits)")[![theodson](https://avatars.githubusercontent.com/u/3782881?v=4)](https://github.com/theodson "theodson (1 commits)")

---

Tags

benchmarkcheckpointcheckpointslaravellaravel-benchmarkphpramlaravelbenchmark

### Embed Badge

![Health badge](/badges/janiaje-benchmark/health.svg)

```
[![Health](https://phpackages.com/badges/janiaje-benchmark/health.svg)](https://phpackages.com/packages/janiaje-benchmark)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[firefly-iii/data-importer

Firefly III Data Import Tool.

7905.8k](/packages/firefly-iii-data-importer)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

98145.2k3](/packages/nickurt-laravel-akismet)[creasi/laravel-nusa

A Laravel package that aim to provide Indonesia' Administrative Data

987.7k2](/packages/creasi-laravel-nusa)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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