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 6y agoCompare

[ Source](https://github.com/hosseinmousavi/pench)[ Packagist](https://packagist.org/packages/hosseinmousavi/pench)[ RSS](/packages/hosseinmousavi-pench/feed)WikiDiscussions master Synced 3d 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 14% 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://www.gravatar.com/avatar/5f5cc9d79ba5ae36e7a83ff2aa9df8c3210157e3bd25639dd4be43ac2d4b0261?d=identicon)[hosseinmousavi](/maintainers/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

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

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