PHPackages                             bluetree-service/benchmark - 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. bluetree-service/benchmark

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

bluetree-service/benchmark
==========================

Class Benchmark libraries

0.5.1.1(7y ago)037[5 issues](https://github.com/bluetree-service/benchmark/issues)Apache-2.0PHPPHP &gt;=7.1.0

Since Nov 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/bluetree-service/benchmark)[ Packagist](https://packagist.org/packages/bluetree-service/benchmark)[ Docs](https://github.com/bluetree-service/benchmark)[ RSS](/packages/bluetree-service-benchmark/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (12)Used By (0)

BlueTree Service Benchmark
==========================

[](#bluetree-service-benchmark)

Documentation
-------------

[](#documentation)

### Timer basic usage

[](#timer-basic-usage)

1. Start benchmark by execute `\Benchmark\Performance\Timer::start()`, that will launch time storage.
2. To measure time from *start* time, until some position use `::setMarker('some description')`, that will save time execution and memory usage from start, or previous marker to current position.
3. After we set sime markers, use `::stop()` to halt benchmark.
4. Use `::calculateStats()` to get information about execution time and memory usage.

```
\Benchmark\Performance\Timer::start();

sleep 3;

\Benchmark\Performance\Timer::setMarker('sleep');

sleep 5;

\Benchmark\Performance\Timer::setMarker('another sleep');

\Benchmark\Performance\Timer::stop();
var_dump(\Benchmark\Performance\Timer::calculateStats());
```

5. If you want to get formatted output, look down for **Timer formatting output** section.

### Timer advanced usage

[](#timer-advanced-usage)

For more cleared view, we can join stats into groups, to see, how mutch time and memory use whole group. To begin measure in group use `::startGroup('group name')`, set markers inside and use `::endGroup('group name')` with the same name to store stats inside one group. Of course there is possibility to create nested groups.

### Timer other functions

[](#timer-other-functions)

- **start()** can have additional boolean argument, if false, then will whole timer will be disabled
- **turnOffBenchmark()** allow to turn off Timer
- **turnOnBenchmark()** allow to turn on Timer

### Timer formatting output

[](#timer-formatting-output)

There are three possibilities to get formatted output. First one allow to ger output as array with formatted time, memory and percentage values. second one allow to get output formatted by *Symfony Console* output class. And last one allow to get output as *HTML*.

#### Pre-formatted array

[](#pre-formatted-array)

After `\Benchmark\Performance\Timer::stop();` execute `(Timer::getFormattedOutput('raw+')` to get array with formatted memory, time and percentage. Using **raw** as parameter return raw values, the same as usage of `\Benchmark\Performance\Timer::calculateStats();`

#### Console output

[](#console-output)

After `\Benchmark\Performance\Timer::stop();` execute `(Timer::getFormattedOutput('shell')` to get formatted output for console. Output will be equivalent of that:

```
Total application runtime: ~1 001.8280 ms    Total memory usage: ~3602 kB
=========================================================================

val: 0 ~0.0050 ms    0.00050 %    ~0,000 kB
val: 1 ~100.1649 ms    9.99821 %    ~0,000 kB
val: 2 ~100.1842 ms    10.00014 %    ~0,000 kB
val: 3 ~100.1740 ms    9.99912 %    ~0,000 kB
val: 4 ~100.1639 ms    9.99812 %    ~0,000 kB
    example group START
    val: 0 ~100.2018 ms    10.00190 %    ~0,000 kB
    val: 1 ~100.1649 ms    9.99821 %    ~0,000 kB
    val: 2 ~100.1790 ms    9.99962 %    ~0,000 kB
    val: 3 ~100.1539 ms    9.99712 %    ~0,000 kB
    val: 4 ~100.1499 ms    9.99671 %    ~0,000 kB
    example group END

```

#### HTML output

[](#html-output)

After `\Benchmark\Performance\Timer::stop();` execute `(Timer::getFormattedOutput('html')` to get formatted output for browser. Output will be equivalent of that:

```

    Total application runtime: ~1 001.8280 ms&nbsp;&nbsp;&nbsp;&nbsp;Total memory usage: ~3129.140625 kB

    Marker times:

            val: 0
            ~0.0050 ms
            0.00050 %
            ~0,000 kB

```

### Write own output formatter

[](#write-own-output-formatter)

If you want to get data in you own specified format, you can apply it to method `calculateStats`. This method accept `callable` type to process data array before it will be returned.
This is how it looks inside the original code: `self::calculateStats([Formatter::class, 'formatValues']);` - this will execute method `formatValues` from `Formatter::class` class.

### Screenshots

[](#screenshots)

![]()

Install via Composer
--------------------

[](#install-via-composer)

To use packages you can just download package and pace it in your code. But recommended way to use *ClassBenchmark* is install it via Composer. To include *ClassBenchmark*libraries paste into composer json:

```
{
    "require": {
        "chajr/class-benchmark": "version"
    }
}
```

Required for ClassBenchmark libraries (ClassKernel) will be loaded automatically.

Project description
-------------------

[](#project-description)

### Used conventions

[](#used-conventions)

- **Namespaces** - each library use namespaces
- **PSR-4** - [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standard
- **Composer** - [Composer](https://getcomposer.org/) usage to load/update libraries

### Requirements

[](#requirements)

- PHP 5.4 or higher
- DOM extension enabled

Change log
----------

[](#change-log)

All release version changes:
[Change log](https://githib.com/chajr/class-benchmark/CHANGELOG.md "Change log")

License
-------

[](#license)

This bundle is released under the Apache 2.0 license.
[Apache license](https://githib.com/chajr/class-benchmark/LICENSE "Apache license")

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~151 days

Recently: every ~263 days

Total

8

Last Release

2699d ago

PHP version history (2 changes)0.2.0PHP &gt;=5.4.0

0.5.0.0PHP &gt;=7.1.0

### Community

Maintainers

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

---

Top Contributors

[![chajr](https://avatars.githubusercontent.com/u/1511381?v=4)](https://github.com/chajr "chajr (33 commits)")

---

Tags

debuggerbenchmarkexecution timeclass librarytracer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bluetree-service-benchmark/health.svg)

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

###  Alternatives

[tracy/tracy

😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

1.8k24.4M1.3k](/packages/tracy-tracy)[vasek-purchart/tracy-blue-screen-bundle

This bundle lets you use the Tracy's debug screen in combination with the the default profiler in your Symfony application.

1177.6k](/packages/vasek-purchart-tracy-blue-screen-bundle)[kuria/error

Makes handling and debugging PHP errors suck less

1920.0k2](/packages/kuria-error)[sandstorm/plumber

Profiling Toolkit for Neos Flow and Neos

364.9k](/packages/sandstorm-plumber)

PHPackages © 2026

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