PHPackages                             mts7/benchmarks - 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. mts7/benchmarks

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

mts7/benchmarks
===============

PHP Benchmarks

3.0.2(1y ago)02MITPHPPHP ^8.2CI passing

Since Nov 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mts7/Benchmarks)[ Packagist](https://packagist.org/packages/mts7/benchmarks)[ RSS](/packages/mts7-benchmarks/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (12)Used By (0)

Benchmarks
==========

[](#benchmarks)

A framework for benchmarking simple functionality

[![codecov](https://camo.githubusercontent.com/f94bd92a60653816ad35fef485c041847715227756fb4495c350b26665e6fade/68747470733a2f2f636f6465636f762e696f2f6769746875622f6d7473372f42656e63686d61726b732f67726170682f62616467652e7376673f746f6b656e3d4c59494f5143384e4b5a)](https://codecov.io/github/mts7/Benchmarks)

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

[](#installation)

```
composer require --dev mts7/Benchmarks --prefer-dist
```

Usage
-----

[](#usage)

Benchmarks includes a [container](https://github.com/mts7/php-dependency-injection) for dependency injection, which makes setting up the benchmark quicker and easier.

```
$container = \MtsBenchmarks\Factory\ContainerFactory::create();
```

### Single Method Call

[](#single-method-call)

The `run` method accepts an array of callables and will execute each callable for the number of iterations per sample for the number of samples and provides the callable with a parameter of the current iteration. All the necessary steps to benchmark are included in the correct order by using the `run` method.

After calling `run`, any report class can accept the results and process them.

```
$samples = 5;
$iterations = 100;
$title = 'callable name';

$benchmark = $container->get(\MtsBenchmarks\Benchmark::class,
    [
        $container->get(\MtsBenchmarks\Helper\IncrementIntegerIterator::class, [$samples]),
        $container->get(\MtsBenchmarks\Helper\IncrementIntegerIterator::class, [$iterations]),
    ]
);

$results = $benchmark->run(['callable']);

$report = $container->get(\MtsBenchmarks\Report\ConsoleReport::class);

echo $report->generate($samples, $iterations, $title, $results);
```

### Multiple Method Calls

[](#multiple-method-calls)

In this form, the framework provides the time calculation results of each callable rather than the raw data. Output formatting is handled by a report object.

```
$samples = 5;
$iterations = 100;
$title = 'callable name';

$benchmark = $container->get(\MtsBenchmarks\Benchmark::class,
    [
        $container->get(\MtsBenchmarks\Helper\IncrementIntegerIterator::class, [$samples]),
        $container->get(\MtsBenchmarks\Helper\IncrementIntegerIterator::class, [$iterations]),
    ]
);
$report = $container->get(\MtsBenchmarks\Report\ConsoleReport::class);

$output = $report->buildTitle($samples, $iterations, $title);
$output .= $report->buildHeaders($title);
$results = $benchmark->run(['callable']);
$output .= $report->buildResults($results);

echo $output;
```

When there is only one callable to check or a desire or preference to test each callable independently (without the framework), `buildSamples` will work. This is the internal method that calls the callable and sets up timing.

```
// raw durations from executing the callable $iterations times per sample
$durations = $benchmark->buildSamples('callable');
```

Comparisons
-----------

[](#comparisons)

The framework does show the users which subjects under test perform quicker than others and by how much, meaning this is a useful tool for comparison rather than for timing.

While the framework handles the timing and execution of the subjects under test, it does not handle the creation or organization of the subjects under test. Since each system is different, there are no constant times for any of the benchmarks across systems.

On a MacBook Pro with M1 Pro, some benchmarks were 2.5 times longer than running with a smaller version of this framework. The base benchmark times on the same system took 2 times longer to execute than on [PHP Sandbox](https://onlinephp.io).

Future Enhancements
-------------------

[](#future-enhancements)

- increase speed/performance
- add additional report options (like HTML, XML)
- add timing and memory usage in ConsoleReport output
- allow benchmark functions to have any number of parameters rather than requiring an int

Included Benchmarks
-------------------

[](#included-benchmarks)

Note these are not included in the distribution package and are only available in the source.

```
composer require --dev mts7/Benchmarks --prefer-source
```

- [Array Iterator](benchmarks/array-iterator.php)
- [Array Merge](benchmarks/array-merge.php)
- [Array Unique](benchmarks/array-unique.php)
    - This uses the `DS` PECL extension to test `Set`
- [Empty Array](benchmarks/empty-array.php)
- [Is Even](benchmarks/is-even.php)

All of these benchmarks are ready to execute by running `php benchmarks/{file-name}.php`.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 82% 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 ~59 days

Recently: every ~98 days

Total

11

Last Release

690d ago

Major Versions

1.2.2 → 2.0.02022-11-04

2.1.4 → 3.0.02023-11-08

PHP version history (2 changes)2.1.0PHP ^8.1

2.1.3PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![mts7](https://avatars.githubusercontent.com/u/292491?v=4)](https://github.com/mts7 "mts7 (73 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M678](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M753](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M571](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.0k](/packages/orchestra-testbench)

PHPackages © 2026

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