PHPackages                             esi/bench - 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. esi/bench

ActiveLibrary

esi/bench
=========

Micro PHP library for benchmarking

v3.2.0(2mo ago)462[1 issues](https://github.com/ericsizemore/bench/issues)MITPHPPHP &gt;=8.2CI passing

Since Feb 9Pushed 1mo agoCompare

[ Source](https://github.com/ericsizemore/bench)[ Packagist](https://packagist.org/packages/esi/bench)[ Docs](https://github.com/ericsizemore/bench)[ GitHub Sponsors](https://github.com/ericsizemore)[ Fund](https://ko-fi.com/ericsizemore)[ RSS](/packages/esi-bench/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (11)Versions (8)Used By (0)

Bench
=====

[](#bench)

[![Build Status](https://camo.githubusercontent.com/8f4fadf6996fe0985f108a59854b71921c3104c0e0fda8506b8394334869ea8c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f62656e63682f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ericsizemore/bench/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/fe7edb0280f62d21c715ee166b37d956e37a78dd70f4bc0e889a110aa50999f9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f62656e63682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ericsizemore/bench/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2631eceb75506c6a190fd4f74b3320d4ab9ad67163a8d77a7cdd6cf641ebf130/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f62656e63682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ericsizemore/bench/?branch=master)[![Continuous Integration](https://github.com/ericsizemore/bench/actions/workflows/continuous-integration.yml/badge.svg?branch=master)](https://github.com/ericsizemore/bench/actions/workflows/continuous-integration.yml)[![Type Coverage](https://camo.githubusercontent.com/ea78a02936125084ffec7f8a5c63a06dff18108bcea2b91ff2fbe1085ff9309c/68747470733a2f2f73686570686572642e6465762f6769746875622f6572696373697a656d6f72652f62656e63682f636f7665726167652e737667)](https://shepherd.dev/github/ericsizemore/bench)[![Psalm Level](https://camo.githubusercontent.com/fee5b0670f3297c41b5f5c4f6322fad531b3e0aa3b3266837c2bd34364a612e3/68747470733a2f2f73686570686572642e6465762f6769746875622f6572696373697a656d6f72652f62656e63682f6c6576656c2e737667)](https://shepherd.dev/github/ericsizemore/bench)[![Latest Stable Version](https://camo.githubusercontent.com/c778c85796387e603e61150063190e038ae0752b93defe57181c602d727afb20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6573692f62656e63682e737667)](https://packagist.org/packages/esi/bench)[![Downloads per Month](https://camo.githubusercontent.com/fc4ac4d14bb8f5b2b2159695009972491e018eb6ac33d0f60eb7efaf11fe2500/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6573692f62656e63682e737667)](https://packagist.org/packages/esi/bench)[![License](https://camo.githubusercontent.com/4bfc95528c03955de8ddcec27e35d21c8e7b62981cd6a14812347a3ff03c8c5d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6573692f62656e63682e737667)](https://packagist.org/packages/esi/bench)

`Bench` is a PHP micro library for benchmark.

Note

This library is a fork of [devster/ubench](https://github.com/devster/ubench) v2.1.0.

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

[](#installation)

### Composer

[](#composer)

Run the following command to install the package

```
composer require esi/bench:~3.0.0
```

Usage
-----

[](#usage)

```
require_once 'vendor/autoload.php';

$bench = new Bench;

$bench->start();

// Execute some code

$bench->end();

// Get elapsed time and memory.
echo $bench->getTime(); // 156ms or 1.123s
echo $bench->getTime(true); // elapsed microtime in float
echo $bench->getTime(false, '%d%s'); // 156ms or 1s

echo $bench->getMemoryPeak(); // 152B or 90.00Kb or 15.23Mb
echo $bench->getMemoryPeak(true); // memory peak in bytes
echo $bench->getMemoryPeak(false, '%.3f%s'); // 152B or 90.152Kb or 15.234Mb

// Returns the memory usage at the end mark.
echo $bench->getMemoryUsage(); // 152B or 90.00Kb or 15.23Mb

// Runs `Bench::start()` and `Bench::end()` around a callable.
// Accepts a callable as the first parameter.  Any additional parameters will be passed to the callable.
$result = $bench->run(function (int $x): int {
    return $x;
}, 1);
echo $bench->getTime();
```

About
-----

[](#about)

### Requirements

[](#requirements)

- PHP &gt;= 8.2

### Credits

[](#credits)

- [Eric Sizemore](https://github.com/ericsizemore)
- [All Contributors](https://github.com/ericsizemore/bench/contributors)

And thanks to the library this is a fork of, [devster/ubench](https://github.com/devster/ubench):

- [Jeremy Perret](https://github.com/devster)
- [All uBench Contributors](https://github.com/devster/ubench/graphs/contributors)

### Contributing

[](#contributing)

See [CONTRIBUTING](./CONTRIBUTING.md).

Bugs and feature requests are tracked on [GitHub](https://github.com/ericsizemore/bench/issues).

### Contributor Covenant Code of Conduct

[](#contributor-covenant-code-of-conduct)

See [CODE\_OF\_CONDUCT.md](./CODE_OF_CONDUCT.md)

### Backward Compatibility Promise

[](#backward-compatibility-promise)

See [backward-compatibility.md](./backward-compatibility.md) for more information on Backwards Compatibility.

### Changelog

[](#changelog)

See the [CHANGELOG](./CHANGELOG.md) for more information on what has changed recently.

### License

[](#license)

See the [LICENSE](./LICENSE.md) for more information on the license that applies to this project.

### Security

[](#security)

See [SECURITY](./SECURITY.md) for more information on the security disclosure process.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance83

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.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 ~187 days

Total

5

Last Release

79d ago

PHP version history (2 changes)v3.0.0PHP ^8.2 &lt;8.5

v3.2.0PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (531 commits)")[![ericsizemore](https://avatars.githubusercontent.com/u/723810?v=4)](https://github.com/ericsizemore "ericsizemore (81 commits)")[![devster](https://avatars.githubusercontent.com/u/1135083?v=4)](https://github.com/devster "devster (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![antoniogarcia78](https://avatars.githubusercontent.com/u/1194110?v=4)](https://github.com/antoniogarcia78 "antoniogarcia78 (1 commits)")[![natebrunette](https://avatars.githubusercontent.com/u/1831497?v=4)](https://github.com/natebrunette "natebrunette (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![asadku34](https://avatars.githubusercontent.com/u/2770949?v=4)](https://github.com/asadku34 "asadku34 (1 commits)")

---

Tags

microlibrarybenchmarkbench

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/esi-bench/health.svg)

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

###  Alternatives

[filp/whoops

php error handling for cool kids

13.2k402.4M1.4k](/packages/filp-whoops)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[devster/ubench

Micro PHP library for benchmarking

5701.0M29](/packages/devster-ubench)[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.2k49.9M1.3k](/packages/slim-slim)[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[bephp/router

A fast router for PHP. It matches urls and executes PHP functions. automatic get variable based on handler function parameter list. Suport to compile router callback handlers into plain array source code.

1611.1k2](/packages/bephp-router)

PHPackages © 2026

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