PHPackages                             best-served-cold/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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. best-served-cold/benchmark

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

best-served-cold/benchmark
==========================

Benchmark - PHP Standalone Benchmark class.

1.0.4(9y ago)26MITPHP

Since Mar 11Pushed 9y ago2 watchersCompare

[ Source](https://github.com/nark3d/Benchmark)[ Packagist](https://packagist.org/packages/best-served-cold/benchmark)[ Docs](http://bestservedcold.com)[ RSS](/packages/best-served-cold-benchmark/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (5)Versions (6)Used By (0)

[![Build Status](https://camo.githubusercontent.com/e80c23cb38dddb048ce98174973bce61beaea0030c3bc0b21d9dc7cb2d30ef4f/68747470733a2f2f7472617669732d63692e6f72672f6e61726b33642f42656e63686d61726b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nark3d/Benchmark)[![Build Status](https://camo.githubusercontent.com/27c9698a8e47dc88a02f5ce579052e183eb056cd3caa1da9ed236ad62fd03e2e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e61726b33642f42656e63686d61726b2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nark3d/Benchmark/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/d3a11cae16b6989cb6d6e5356a4ebb26dab873011442a4c0cf43c7ce573a5cfd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e61726b33642f42656e63686d61726b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nark3d/Benchmark/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/303aec24cb9aaa90cc70afd7c3ec7501830e31f56832189224ba0c681cf273a8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e61726b33642f42656e63686d61726b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nark3d/Benchmark/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/a475e356bbd87790f651cd1c03e7eae0d3e0c3c33404b2fb676864e1db4b0706/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37643235316534652d393664662d346135302d623666372d3766613134383938323637382f6d696e692e706e67)](https://insight.sensiolabs.com/projects/7d251e4e-96df-4a50-b6f7-7fa148982678)[![Latest Stable Version](https://camo.githubusercontent.com/f4773b252adfabfbc9834bb9af31a6a9907bcb408954ddeb3b29e6381bb9f61d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626573742d7365727665642d636f6c642f62656e63686d61726b2e737667)](https://packagist.org/packages/best-served-cold/benchmark)

Benchmark
=========

[](#benchmark)

Install
-------

[](#install)

```
$ composer require best-served-cold/benchmark
```

Usage
-----

[](#usage)

Call in the Benchmark and Output classes

```
use BestServedCold\Benchmark\Benchmark;
use BestServedCold\Benchmark\Output;
```

Then benchmark a bunch of code:

```
Benchmark::start();
for ($i = 0; $i render();
```

Returns something like this:

```
+---------------+-------------------+--------------------+
| Name          | Metric            | Value              |
+---------------+-------------------+--------------------+
| 58c4302514614 | MicroTime         | 0.0022561550140381 |
| 58c4302514614 | MemoryUsage       | 160.05 KB          |
| 58c4302514614 | DeclaredInterface | 0                  |
| 58c4302514614 | DeclaredTrait     | 2                  |
| 58c4302514614 | DefinedFunction   | 0                  |
| 58c4302514614 | DefinedConstant   | 0                  |
| 58c4302514614 | IncludedFile      | 1                  |
| 58c4302514614 | DeclaredClass     | 0                  |
| 58c4302514614 | PeakMemoryUsage   | 1.54 MB            |
+---------------+-------------------+--------------------+
```

As no $name argument is specified, a hashed name will be given as means of identification.

Naming benchmarks
-----------------

[](#naming-benchmarks)

```
Benchmark::reset(); // Clear existing benchmarks
Benchmark::start('bob');
$a = str_repeat('Hello', 24000);
define('FOO', 'bar');
Benchmark::stop('bob');
Benchmark::start('mary');
require_once('./SomeClass.php');
sleep(1);
Benchmark::stop('mary');
```

Returns something like:

```
+------+-------------------+--------------------+
| Name | Metric            | Value              |
+------+-------------------+--------------------+
| bob  | MicroTime         | 0.0014297962188721 |
| bob  | MemoryUsage       | 191.77 KB          |
| bob  | DeclaredInterface | 0                  |
| bob  | DeclaredTrait     | 0                  |
| bob  | DefinedFunction   | 0                  |
| bob  | DefinedConstant   | 1                  |
| bob  | IncludedFile      | 0                  |
| bob  | DeclaredClass     | 0                  |
| bob  | PeakMemoryUsage   | 2.18 MB            |
+------+-------------------+--------------------+
| mary | MicroTime         | 1.0012910366058    |
| mary | MemoryUsage       | 75.48 KB           |
| mary | DeclaredInterface | 0                  |
| mary | DeclaredTrait     | 0                  |
| mary | DefinedFunction   | 0                  |
| mary | DefinedConstant   | 0                  |
| mary | IncludedFile      | 1                  |
| mary | DeclaredClass     | 1                  |
| mary | PeakMemoryUsage   | 2.18 MB            |
+------+-------------------+--------------------+
```

Specifying output interface
---------------------------

[](#specifying-output-interface)

```
Benchmark::reset();
Benchmark::start('susan');
require_once('./SomeTrait.php');
Benchmark::stop('susan');
Output::output(Benchmark::get(), 'apache')->render();
```

Returns something like:

    Name   Metric   Value       susan   MicroTime   0.0014090538024902     susan   MemoryUsage   76.03 KB     susan   DeclaredInterface       susan   DeclaredTrait   1     susan   DefinedFunction       susan   DefinedConstant       susan   IncludedFile   1     susan   DeclaredClass       susan   PeakMemoryUsage   2.18 MB

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 92.6% 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 ~0 days

Total

5

Last Release

3397d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7125bc235342a06ced0cf7952c93d388ab150f899b1c711e91d018943ad8c93?d=identicon)[nark3d](/maintainers/nark3d)

---

Top Contributors

[![nark3d](https://avatars.githubusercontent.com/u/2162621?v=4)](https://github.com/nark3d "nark3d (25 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

profilerbenchmarkBest Served ColdPeformance

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/best-served-cold-benchmark/health.svg)

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

###  Alternatives

[sandstorm/plumber

Profiling Toolkit for Neos Flow and Neos

364.9k](/packages/sandstorm-plumber)

PHPackages © 2026

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