PHPackages                             eypsilon/mycrobench - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. eypsilon/mycrobench

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eypsilon/mycrobench
===================

MycroBench | Lightweight time measure tool for PHP

v1.0.4(3y ago)226MITPHPPHP &gt;=7.4CI passing

Since Sep 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/eypsilon/MycroBench)[ Packagist](https://packagist.org/packages/eypsilon/mycrobench)[ RSS](/packages/eypsilon-mycrobench/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)DependenciesVersions (5)Used By (0)

MycroBench | Lightweight time measure tool for PHP
==================================================

[](#mycrobench--lightweight-time-measure-tool-for-php)

This Package uses `$_SERVER['REQUEST_TIME_FLOAT']` and `microtime()` to calculate the difference that has passed between both times, when instantiated. It also provides a basic implementation of `hrtime()`, which allows measuring processing times with higher precision.

See [./public/index.php](./public/index.php) for examples or check the livedemo on [Vercel](https://mycro-bench.vercel.app/).

```
composer require eypsilon/MycroBench

```

```
use Many\MycroBench;

/**
 * @return array basic usage
 */
MycroBench::get()

// Array
// (
//     [start] => 2022-10-10 16:07:00.172129
//     [ended] => 2022-10-10 16:07:00.302257
//     [took] => 00.130128
//     [mem_usage] => 376.21 KB
//     [mem_peak] => 16.37 MB
//     [included_files_total] => 37
// )
```

Consecutive requests
--------------------

[](#consecutive-requests)

Get the processing time that has passed between consecutive requests with internally staid `start` times.

The first request will use `$_SERVER['REQUEST_TIME_FLOAT']` as `start` time, subsequent requests will use the `ended` time from previous requests.

Set the initial start time for benches manually to *now*. This is optional, but the first high resolution time will be wrong, if it's not instantiated.

```
/** Sets the start time for @method getBench() and @method hrBench() to now */
MycroBench::initBench()
```

```
/** @param bool true returns additional high resolution times */
MycroBench::getBench(true)

// [start] => 2022-10-10 16:07:00.176997
// [ended] => 2022-10-10 16:07:00.217398
// [took] => 00.040401
// [h_res] => 0.040415356

MycroBench::getBench(true)

// [start] => 2022-10-10 16:07:00.217398
// [ended] => 2022-10-10 16:07:00.239846
// [took] => 00.022448
// [h_res] => 0.022439554

MycroBench::getBench(true)

// [start] => 2022-10-10 16:07:00.239846
// [ended] => 2022-10-10 16:07:00.265409
// [took] => 00.025563
// [h_res] => 0.025560282
```

High resolution times
---------------------

[](#high-resolution-times)

Get `microtimes` with the system's high resolution time using [hrtime()](https://www.php.net/manual/de/function.hrtime.php).

Microsec: `00.019045`

High Reso: `0.019044332`

```
// start bench
MycroBench::hrStart()

// do stuff here

// end bench, set first param true to get the result in return
MycroBench::hrEnd(false)

/** @return float|null '0.019044332' */
MycroBench::hrGet()
```

Get high resolution times with internally staid start times.

```
/** @return float|null '0.019044332' */
MycroBench::hrBench()
```

#### Misc

[](#misc)

```
/**
 * microtimestamp to datetime
 *
 * @return string '2022-09-01 17:14:48.5000'
 */
(new MycroBench)->getDate('1662045288.5000') # 'U.u', 'Y-m-d H:i:s.u'

/**
 * datetime to microtimestamp
 *
 * @return string '1662045288.5000'
 */
(new MycroBench)->getDateToMicro('2022-09-01 17:14:48.5000') #'Y-m-d H:i:s.u', 'U.u'

/**
 * Get microtimestamp for the last request. Only filled
 * when @method getBench() has been called
 *
 * @return string|null '1662623500.7135'
 */
MycroBench::getLastDate()

/**
 * Readable bytes
 *
 * @return string '379.67 KB'
 */
MycroBench::readableBytes(memory_get_usage())

/**
 * Default getter
 *
 * start: $_SERVER['REQUEST_TIME_FLOAT']
 * ended: microtime(true)
 *
 * @static alias MycroBench::get()
 *
 * @param bool   enable (array) get_included_files()
 * @param string set a needle to shorten the paths returned in get_included_files()
 * @return array
 */
(new MycroBench)->getAll(true, '/remove/from/included_files/paths')

/**
 * Consecutive getter
 *
 * @static alias MycroBench::getBench()
 *
 * @param bool get additionally higher resolution times
 * @return array
 */
(new MycroBench)->getBenchDiff(true)
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

4

Last Release

1214d ago

### Community

Maintainers

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

---

Top Contributors

[![eypsilon](https://avatars.githubusercontent.com/u/27016183?v=4)](https://github.com/eypsilon "eypsilon (10 commits)")

---

Tags

measuremicrotimephp

### Embed Badge

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

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

###  Alternatives

[alexwight/php-signalr-client

Signal R Client

2331.9k](/packages/alexwight-php-signalr-client)[aertmann/history

An improved history backend module for Neos

1174.6k](/packages/aertmann-history)[pixelfederation/circuit-breaker-bundle

An analogous bundle to Java's Hystrix in PHP world.

1229.0k](/packages/pixelfederation-circuit-breaker-bundle)

PHPackages © 2026

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