PHPackages                             alecrabbit/php-simple-profiler - 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. alecrabbit/php-simple-profiler

AbandonedLibrary

alecrabbit/php-simple-profiler
==============================

For functions benchmarking, contain counters and timers classes.

0.5.2(7y ago)0571MITPHPPHP ^7.2

Since Nov 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/alecrabbit/php-simple-profiler)[ Packagist](https://packagist.org/packages/alecrabbit/php-simple-profiler)[ RSS](/packages/alecrabbit-php-simple-profiler/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (9)Versions (22)Used By (0)

PHP Simple profiler
===================

[](#php-simple-profiler)

[![PHP Version](https://camo.githubusercontent.com/3b16c3279d530f739a57244961847811e1f3b79a7979dec395e30738abe1807d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616c65637261626269742f7068702d73696d706c652d70726f66696c65722e737667)](https://php.net/)[![Build Status](https://camo.githubusercontent.com/084bf9696fcbcfe2b3629b28e34bfec4a52c3183cd3786d87f74264ee1691349/68747470733a2f2f7472617669732d63692e636f6d2f616c65637261626269742f7068702d73696d706c652d70726f66696c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/alecrabbit/php-simple-profiler)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ee714b0e478314b53880f98fa89cc8aeb4c193eefb788b373cac8971c75a2711/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65637261626269742f7068702d73696d706c652d70726f66696c65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alecrabbit/php-simple-profiler/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/3569de2a24b22983585a82b11125bb8658ce0bc62860ea70f1e6667a4018a33c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65637261626269742f7068702d73696d706c652d70726f66696c65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alecrabbit/php-simple-profiler/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/1b4db50b32a2d2ce3c40e444d0123aa6ecf6bae55b9e22a7d8460f38d9540f77/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d73696d706c652d70726f66696c65722f646f776e6c6f616473)](https://packagist.org/packages/alecrabbit/php-simple-profiler)

[![Latest Stable Version](https://camo.githubusercontent.com/cf3215e57ebc288fb34c0ee969c721a2f36991d77888a1e8db15053f2bbc49ed/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d73696d706c652d70726f66696c65722f762f737461626c65)](https://packagist.org/packages/alecrabbit/php-simple-profiler)[![Latest Version](https://camo.githubusercontent.com/346db3e86a4db2901594b0f307e5382d0debc4c9210f7b543054093803d67609/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c65637261626269742f7068702d73696d706c652d70726f66696c65722e737667)](https://packagist.org/packages/alecrabbit/php-simple-profiler)[![Latest Unstable Version](https://camo.githubusercontent.com/dc5766c08f65d78d05901451171bc60862bb5aadf1645c03c8943ce3697bf271/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d73696d706c652d70726f66696c65722f762f756e737461626c65)](https://packagist.org/packages/alecrabbit/php-simple-profiler)

[![License](https://camo.githubusercontent.com/525664f35521658b5bdcb5e27b8517cf3c27bc8dab064b5557953a1232abe712/68747470733a2f2f706f7365722e707567782e6f72672f616c65637261626269742f7068702d73696d706c652d70726f66696c65722f6c6963656e7365)](https://packagist.org/packages/alecrabbit/php-simple-profiler)[![Average time to resolve an issue](https://camo.githubusercontent.com/8cef0a65d3835da77b1dd72dd54a1103d4f192f0380c00727a22a1198cd86e9a/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f7265736f6c7574696f6e2f616c65637261626269742f7068702d73696d706c652d70726f66696c65722e737667)](http://isitmaintained.com/project/alecrabbit/php-simple-profiler "Average time to resolve an issue")[![Percentage of issues still open](https://camo.githubusercontent.com/fceebacf37175bd1cb278d69246921a0642243aac3acffc3ab0a78ba308e9a72/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f6f70656e2f616c65637261626269742f7068702d73696d706c652d70726f66696c65722e737667)](http://isitmaintained.com/project/alecrabbit/php-simple-profiler "Percentage of issues still open")

### Demos

[](#demos)

See [demos](docs/demos.md)

### Quickstart

[](#quickstart)

##### Benchmark

[](#benchmark)

```
use AlecRabbit\Tools\BenchmarkSymfonyProgressBar;

require_once __DIR__ . '/vendor/autoload.php';

$benchmark = new BenchmarkSymfonyProgressBar(900000);
$benchmark
    ->addFunction('hrtime', true);
$benchmark
    ->addFunction('microtime', true);
echo $benchmark->run()->noReturns()->report() . PHP_EOL;
echo $benchmark->stat() . PHP_EOL;
```

Output will be something like:

```
Results:
Benchmark:
1.  150.1ns (  0.00%) ⟨1⟩ hrtime(boolean)
2.  157.7ns (  5.07%) ⟨2⟩ microtime(boolean)
Benchmarked: 2
Memory: 0.88MB(0.92MB) Real: 2.00MB(2.00MB)

Done in: 2.0s

```

###### For more details see [examples](https://github.com/alecrabbit/php-simple-profiler/tree/master/examples)

[](#for-more-details-see-examples)

> Note: Some examples could be not up to date... WIP

WIP
===

[](#wip)

### Installation

[](#installation)

For now this package is suggested to be used in dev process

```
composer require --dev alecrabbit/php-simple-profiler
```

or if you wish

```
composer require alecrabbit/php-simple-profiler
```

### Benchmark classes

[](#benchmark-classes)

There are moments when you have to choose between two or more different approaches. Benchmark classes is to help you choose which is faster :)

- `Benchmark::class` (no default progress bar, silent measurements)
- `BenchmarkSymfonyPB::class` (with Symfony progress bar)

```
 26% [████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░]  1 sec/4 secs

```

- `BenchmarkSimplePB::class` (with star progress bar)

```
******************************

```

##### Example

[](#example)

Let's say you want to know which is faster `call_user_func($func)` or `$func()`. First you need to create an instance of Benchmark class

```
$b = new BenchmarkSymfonyPB(900000) // with Symfony Progress bar, 900000 measurments
```

> Note: Xdebug extension slowing things down a lot! Disable it (I'm using two different images [w/o Xdebug](https://github.com/alecrabbit/php-simple-profiler/tree/master/docker-compose.yml) and [with Xdebug](https://github.com/alecrabbit/php-simple-profiler/tree/master/docker-compose-debug.yml))

Then you have to add functions to test. But first let's add a closure:

```
$func = function (array $a) {
    return array_sum($a);
};
```

Now we are ready to add functions:

```
$a = [1, 2, 3];

$b->addFunction('call_user_func', $func, $a);

$b->addFunction($func, $a);
```

And now you can run the benchmarking

```
$b->run();
```

Getting results

```
$report = $b->report(); // you can get report object and use data from it
echo $report . PHP_EOL; // or you can print it by default formatter
echo $b->stat() . PHP_EOL;
```

Results will be something like that

```
Results:
Benchmark:
1.  219.3ns (  0.00%) $func(array) $func(...$args)
2.  287.4ns ( 31.09%) call_user_func(array) \call_user_func($func, ...$args)
All returns are equal:
integer(6)
Benchmarked: 2
Memory: 0.87MB(0.91MB) Real: 2.00MB(2.00MB)

Done in: 1.1s

```

### Profiler::class

[](#profilerclass)

Profiler is a kinda wrapper for Counter and Timer in case if you need them both.

```
$profiler = new Profiler();

for ($i = 0; $i < 100; $i++) {
    $profiler->counter()->bump();
    someOperation();
    $profiler->timer()->check();
}

echo $profiler->report() . PHP_EOL;
```

### Counter::class

[](#counterclass)

// todo

### Timer::class

[](#timerclass)

// todo

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

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 ~14 days

Recently: every ~25 days

Total

17

Last Release

2482d ago

PHP version history (2 changes)0.0.15PHP &gt;=7.2

0.5.2PHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![alecrabbit](https://avatars.githubusercontent.com/u/11045453?v=4)](https://github.com/alecrabbit "alecrabbit (521 commits)")

---

Tags

benchmarkbenchmarkingbenchmarkscountercounterstimertimersprofilertimerSimplecounterbenchmarkmicrotime

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alecrabbit-php-simple-profiler/health.svg)

```
[![Health](https://phpackages.com/badges/alecrabbit-php-simple-profiler/health.svg)](https://phpackages.com/packages/alecrabbit-php-simple-profiler)
```

###  Alternatives

[jsanc623/phpbenchtime

A lightweight benchmark timer and lap profiler for PHP.

2539.1k1](/packages/jsanc623-phpbenchtime)[dragon-code/benchmark

Simple comparison of code execution speed between different options

11934.7k5](/packages/dragon-code-benchmark)[ayesh/php-timer

High-resolution and monotonic stop-watch for all your needs. Supports timer start, pause, resume, stop, read, and minimal conversion.

22226.4k11](/packages/ayesh-php-timer)[phpbenchmark/phpbenchmark

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

8011.4k2](/packages/phpbenchmark-phpbenchmark)[sandstorm/plumber

Profiling Toolkit for Neos Flow and Neos

384.9k](/packages/sandstorm-plumber)

PHPackages © 2026

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