PHPackages                             ggomuk/g-bench - 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. ggomuk/g-bench

ActiveLibrary

ggomuk/g-bench
==============

PHP Benchmark Component

1.0.0(7y ago)3121MITPHPPHP ~7.1

Since Feb 13Pushed 7y agoCompare

[ Source](https://github.com/ggomuk/g-bench)[ Packagist](https://packagist.org/packages/ggomuk/g-bench)[ RSS](/packages/ggomuk-g-bench/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

G-Bench [![Build Status](https://camo.githubusercontent.com/2bd279a5656d19b24eb6ab8c089bcffea73e05936e075c533eea2e46635ca3b2/68747470733a2f2f7472617669732d63692e636f6d2f67676f6d756b2f672d62656e63682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ggomuk/g-bench)
=================================================================================================================================================================================================================================================================================

[](#g-bench-)

G-Bench is a nice and **light** component for `php benchmarking`.

---

### Installation

[](#installation)

Add this in your `composer.json`

```
{
    "require": {
        "ggomuk/g-bench": "1.0.0"
    }
}
```

---

### Sample Usage

[](#sample-usage)

- **start()**, **stop()**

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

    $gb = new \GBench\GBench();

    $gb->start();
    $temp = str_repeat('Hello World!', 10000);
    sleep(2);
    $gb->stop();

    $gb->getDuration(); // 2003 (ms)
    $gb->getMemory(); // 2097152 (bytes)

    echo $gb; // 2.00 MB - 2003 ms
    ```
- **record()**

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

    $gb = new \GBench\GBench();

    $gb->start();

    usleep(500000);
    $temp1 = str_repeat('Hello World!', 10000);

    // You can label records with the record method.
    // The benchmark does not stop as it only makes an intermediate record.
    $gb->record('step1');

    usleep(500000);
    $temp2 = str_repeat('Hello World!', 100000);

    // You can also label records with the stop method.
    $gb->stop('step2');

    // The details of the record can be seen below
    foreach ($gb->getRecords() as $record) {
        $record->getLabel(); // step1, step2
        $record->getMemory(); // 2097152, 2097152
        $record->getDuration(); // 505, 506
        $record->getAccumulateMemory(); // 2097152, 4194304

        echo $record;
        // Usage Memory : 2.00 MB | Accumulate Usage Memory : 2.00 MB | Record Duration : 505 ms -> step1
        // Usage Memory : 2.00 MB | Accumulate Usage Memory : 4.00 MB | Record Duration : 506 ms -> step2
    }
    ```
- **run()**

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

    $gb = new \GBench\GBench();
    $result = $gb->run(function () {
        usleep(500000);
        return str_repeat('Hello World!', 10000);
    }, 'sample_run');

    $gb->getDuration() . "\n"; // 504 (ms)
    $gb->getMemory() . "\n"; // 2097152 (bytes)
    echo $gb . "\n"; // 2.00 MB - 504 ms
    ```
- **Handler**

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

    $logger = new class extends \GBench\AbstractHandler {
        public function startAfter(\GBench\GBench $gbench)
        {
            echo 'good start';
        }

        public function stopAfter(\GBench\GBench $gbench, \GBench\Record $record)
        {
            echo 'good stop';
        }
    };

    $gb = new \GBench\GBench($logger);
    $gb->start(); // good start
    $gb->stop(); // good stop
    ```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2642d ago

### Community

---

Top Contributors

[![ggomuk](https://avatars.githubusercontent.com/u/22437277?v=4)](https://github.com/ggomuk "ggomuk (5 commits)")

### Embed Badge

![Health badge](/badges/ggomuk-g-bench/health.svg)

```
[![Health](https://phpackages.com/badges/ggomuk-g-bench/health.svg)](https://phpackages.com/packages/ggomuk-g-bench)
```

PHPackages © 2026

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