PHPackages                             devster/ubench - 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. devster/ubench

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

devster/ubench
==============

Micro PHP library for benchmarking

2.1.0(7y ago)5701.0M—1.4%70[2 issues](https://github.com/devster/ubench/issues)[1 PRs](https://github.com/devster/ubench/pulls)20MITPHP

Since Nov 30Pushed 2y ago27 watchersCompare

[ Source](https://github.com/devster/ubench)[ Packagist](https://packagist.org/packages/devster/ubench)[ Docs](https://github.com/devster/ubench)[ RSS](/packages/devster-ubench/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (20)

Ubench [![Build Status](https://camo.githubusercontent.com/ca4c98c1a0add9f8661968fc1ebc667c2c6fe6e5b33e1ac5e15ca5910f6b93ed/68747470733a2f2f7472617669732d63692e6f72672f646576737465722f7562656e63682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/devster/ubench)
================================================================================================================================================================================================================================================================================

[](#ubench-)

Ubench is a PHP micro library for benchmark

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

[](#installation)

Note: If you are looking for this package for laravel application then install it from here [Benchmark](https://packagist.org/packages/asad/benchmark)

### Old school

[](#old-school)

require `src/Ubench.php` in your project.

### Composer

[](#composer)

Add this to your composer.json

```
{
    "require": {
        "devster/ubench": "~2.0.0"
    }
}
```

Usage
-----

[](#usage)

```
require_once 'src/Ubench.php';

$bench = new Ubench;

$bench->start();

// Execute some code

$bench->end();

// Get elapsed time and memory
echo $bench->getTime(); // 156ms or 1.123s
echo $bench->getTime(true); // elapsed microtime in float
echo $bench->getTime(false, '%d%s'); // 156ms or 1s

echo $bench->getMemoryPeak(); // 152B or 90.00Kb or 15.23Mb
echo $bench->getMemoryPeak(true); // memory peak in bytes
echo $bench->getMemoryPeak(false, '%.3f%s'); // 152B or 90.152Kb or 15.234Mb

// Returns the memory usage at the end mark
echo $bench->getMemoryUsage(); // 152B or 90.00Kb or 15.23Mb

// Runs `Ubench::start()` and `Ubench::end()` around a callable
// Accepts a callable as the first parameter.  Any additional parameters will be passed to the callable.
$result = $bench->run(function ($x) {
    return $x;
}, 1);
echo $bench->getTime();
```

License
-------

[](#license)

Ubench is licensed under the MIT License

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity60

Solid adoption and visibility

Community36

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 84.2% 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 ~475 days

Recently: every ~592 days

Total

6

Last Release

2588d ago

Major Versions

1.2.0 → 2.0.02017-11-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1135083?v=4)[Jeremy Perret](/maintainers/devster)[@devster](https://github.com/devster)

---

Top Contributors

[![devster](https://avatars.githubusercontent.com/u/1135083?v=4)](https://github.com/devster "devster (16 commits)")[![antoniogarcia78](https://avatars.githubusercontent.com/u/1194110?v=4)](https://github.com/antoniogarcia78 "antoniogarcia78 (1 commits)")[![asadku34](https://avatars.githubusercontent.com/u/2770949?v=4)](https://github.com/asadku34 "asadku34 (1 commits)")[![natebrunette](https://avatars.githubusercontent.com/u/1831497?v=4)](https://github.com/natebrunette "natebrunette (1 commits)")

---

Tags

microlibrarybenchmarkbench

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69938.4M141](/packages/league-iso3166)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

347.8M3](/packages/dekor-php-array-table)

PHPackages © 2026

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