PHPackages                             phpbenchmark/phpbenchmark - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. phpbenchmark/phpbenchmark

ActiveLibrary[Testing &amp; Quality](/categories/testing)

phpbenchmark/phpbenchmark
=========================

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

1.1.4(9y ago)8011.4k7[1 issues](https://github.com/victorjonsson/PHP-Benchmark/issues)2MITPHPPHP &gt;=5.5.0CI failing

Since May 18Pushed 8y ago7 watchersCompare

[ Source](https://github.com/victorjonsson/PHP-Benchmark)[ Packagist](https://packagist.org/packages/phpbenchmark/phpbenchmark)[ Docs](http://victorjonsson.github.com/PHP-Benchmark/)[ RSS](/packages/phpbenchmark-phpbenchmark/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (6)Used By (2)

PHP-Benchmark
=============

[](#php-benchmark)

This library contains classes used to compare algorithms and benchmark your application.

Benchmarking
------------

[](#benchmarking)

### Setup

[](#setup)

1. Either [download](https://github.com/victorjonsson/PHP-Benchmark/archive/master.zip) the library to your server or install it in your project using [composer](http://getcomposer.org/)
2. Include the file init.php in the very beginning of the first file that receives the request to your application (this is usually index.php). Then load the address of your website in the browser with the query parameters `php-benchmark-test=1` and the benchmark data will be displayed in the upper left corner of your website.

[![Becnhmark 1](https://camo.githubusercontent.com/3813f849fde1a1cfd8e03f5488b6552ffe7a36fe5567f33c7a02caf0c8a9698d/687474703a2f2f766963746f726a6f6e73736f6e2e6769746875622e636f6d2f5048502d42656e63686d61726b2f73632d312e706e67)](https://camo.githubusercontent.com/3813f849fde1a1cfd8e03f5488b6552ffe7a36fe5567f33c7a02caf0c8a9698d/687474703a2f2f766963746f726a6f6e73736f6e2e6769746875622e636f6d2f5048502d42656e63686d61726b2f73632d312e706e67)

#### Taking snapshots

[](#taking-snapshots)

If you want to take snapshots from the benchmark data during the request you may do so by adding the following code.

```
 \PHPBenchmark\Monitor::instance()->snapshot('Bootstrap finished');
```

Inserting some snapshots in the source code of WordPress gave me the following benchmark data

[![Becnhmark 1](https://camo.githubusercontent.com/71327b650c365a1cf85df37adcc7c8776e0402f6b9f4d32bdc730a8a35d210b6/687474703a2f2f766963746f726a6f6e73736f6e2e6769746875622e636f6d2f5048502d42656e63686d61726b2f73632d322e706e67)](https://camo.githubusercontent.com/71327b650c365a1cf85df37adcc7c8776e0402f6b9f4d32bdc730a8a35d210b6/687474703a2f2f766963746f726a6f6e73736f6e2e6769746875622e636f6d2f5048502d42656e63686d61726b2f73632d322e706e67)

Comparing algorithms
--------------------

[](#comparing-algorithms)

### Setup (composer)

[](#setup-composer)

Add the dependency "phpbenchmark/phpbenchmark" to composer.json and your'e set to go.

### Example code

[](#example-code)

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

use \PHPBenchmark\testing\FunctionComparison;

function xrange($start, $limit, $step = 1) {
    if ($start < $limit) {
        if ($step = $limit; $i += $step) {
            yield $i;
        }
    }
}

FunctionComparison::load()
    ->addFunction('using array', function () {
        foreach (range(1, 9, 2) as $number) {}
    })
    ->addFunction('using generator', function () {
        foreach (xrange(1, 9, 2) as $number) {}
    })
    ->exec();
```

Load a file having this code in the browser, or call it via command line, and you will find out that generators consumes less memory but is at the same time considerbly slower.

You can also call `->run()` to get hold of an object representing the results of the comparison test. Read more in the [docs](https://github.com/victorjonsson/PHP-Benchmark/blob/master/DOCS.md#class-phpbenchmarktestingfunctioncomparison).

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 98.4% 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 ~349 days

Total

5

Last Release

3350d ago

PHP version history (3 changes)1.0.1PHP &gt;= 5.3

1.1.0PHP &gt;=5.4.0

1.1.4PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/400fc7363b72aabbb4b7d8cbc241a8d7dffb9ca4844ce4403e9511313192e232?d=identicon)[vic](/maintainers/vic)

---

Top Contributors

[![victorjonsson](https://avatars.githubusercontent.com/u/429182?v=4)](https://github.com/victorjonsson "victorjonsson (63 commits)")[![JDGrimes](https://avatars.githubusercontent.com/u/4005415?v=4)](https://github.com/JDGrimes "JDGrimes (1 commits)")

---

Tags

testprofilerperformancebenchmark

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[php-coveralls/php-coveralls

PHP client library for Coveralls API

51413.7M3.4k](/packages/php-coveralls-php-coveralls)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[jsanc623/phpbenchtime

A lightweight benchmark timer and lap profiler for PHP.

2539.1k1](/packages/jsanc623-phpbenchtime)[zenstruck/console-test

Alternative, opinionated helper for testing Symfony console commands.

58635.0k20](/packages/zenstruck-console-test)[hughsaffar/laravel-test-trap

Laravel Test Trap

18406.8k](/packages/hughsaffar-laravel-test-trap)

PHPackages © 2026

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