PHPackages                             hosseinmousavi/pench - 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. hosseinmousavi/pench

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

hosseinmousavi/pench
====================

Another PHP benchmark system

48PHP

Since May 18Pushed 7y agoCompare

[ Source](https://github.com/hosseinmousavi/pench)[ Packagist](https://packagist.org/packages/hosseinmousavi/pench)[ RSS](/packages/hosseinmousavi-pench/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

pench
=====

[](#pench)

Another PHP benchmark system
----------------------------

[](#another-php-benchmark-system)

**This library benchmark php applications and show time\_elapsed,memory\_usage and memory\_peak\_usage, but you should consider there is no way to get precise amount of memory consumed by the application because there is no way for php to report it, the `memory_get_usage(false)` just report the memory that is allocated not actually using by the application but it's near the real memory usage by the application.**

Install pench via composer

```
composer require hosseinmousavi/pench:dev-master

```

Then include composer autoload file

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

Or just include it

```
require 'src/pench.php';

```

pench API is damn simple, see example below

```
require 'pench.php';
$haystack = rang(1,1000000);

pench::start();
foreach($haystack as $value) {
  echo $value;
}
$report['foreach']=pench::end();
var_dump($report);
```

Will output

```
array (size=1)
  'foreach' =>
    array (size=3)
      'time_elapsed' => string '24.709722042084 Sec' (length=19)
      'memory_usage' => string '112 Byte' (length=8)
      'peak_memory_usage' => string '176 Byte' (length=8)
```

Also you can use dump() to print the report and it's not necessary to call end() because dump itself will call it, it's possible to pass a label to dump() so it'll be clear which result belongs to what part of the program.

```
require 'pench.php';

pench::start();

$haystack = rang(1,1000000);

array_walk($haystack,function($value){

  echo $value;

});

pench::dump('array_walk');
```

will ouput

```
array (size=1)
  'array_walk' =>
    array (size=3)
      'time_elapsed' => string '0.11225986480713 Sec' (length=20)
      'memory_usage' => string '152 Byte' (length=8)
      'peak_memory_usage' => string '176 Byte' (length=8)
```

For benchmarking multiple parts you should call pench::start() every time.

```
pench::start();

foreach($haystack as $value) {

  echo $value;

}

$report['foreach']=pench::end();//or pench::dump('array_foreach') or pench::dump() to print report inline

pench::start();

array_walk($haystack,function($value){

  echo $value;

});

$report['array_walk']=pench::end();//or pench::dump('array_walk') to print report inline
```

use `benchmark()` to fetch last report

```
pench::start();

foreach($haystack as $value) {

  echo $value;

}

pench::end();//or pench::dump('array_foreach') or pench::dump() to print report inline

var_dump(pench::benchmark());
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/61721826?v=4)[hosseinmousavi](/maintainers/hosseinmousavi)[@HosseinMousavi](https://github.com/HosseinMousavi)

---

Top Contributors

[![mirhmousavi](https://avatars.githubusercontent.com/u/2023858?v=4)](https://github.com/mirhmousavi "mirhmousavi (12 commits)")

### Embed Badge

![Health badge](/badges/hosseinmousavi-pench/health.svg)

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

###  Alternatives

[fjogeleit/prometheus-messenger-middleware

Prometheus Middleware for the Symfony Messenger Component

2255.2k](/packages/fjogeleit-prometheus-messenger-middleware)[spatie/craft-ray

Easily debug CraftCMS projects

1638.4k](/packages/spatie-craft-ray)

PHPackages © 2026

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