PHPackages                             eugeneuk/code-timer - 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. eugeneuk/code-timer

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

eugeneuk/code-timer
===================

Simple PHP library to measuring code execution time with memory usage.

070PHP

Since Jan 15Pushed 1y agoCompare

[ Source](https://github.com/eugeneuk/code-timer)[ Packagist](https://packagist.org/packages/eugeneuk/code-timer)[ RSS](/packages/eugeneuk-code-timer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

CodeTimer
=========

[](#codetimer)

Simple PHP library to measuring code execution time with memory usage.

Installation - via composer.json
--------------------------------

[](#installation---via-composerjson)

```
"requtize/code-timer": "^0.1.0"
```

Usage
-----

[](#usage)

```
use Requtize\CodeTimer\CodeTimer;

$timer = new CodeTimer;

// Sets category color which is displayed on some timeline preview.
$timer->setCategoryColor('handle-request', 'green');
$timer->setCategoryColor('controller', 'red');

// Starts and stops recording the request.
// Between those two methods call, all rest methods should be called.
$timer->begin();
$timer->end();

// Opens and closes section.
$timer->openSection('section-name', 'handle-request');
$timer->closeSection('section-name');

// Starts and stops some event to measure its duration and memory.
// It will be attached to current opened section
$timer->start('some event', 'controller');
$timer->stop('some event');

// Exports collected data to predefined formats.
$data = $timer->exportToArray();
$data = $timer->exportToJson();
```

Result array
------------

[](#result-array)

```
$data = [
    'total-time' => [
        'start'    => 15623363564,
        'end'      => 15623373668,
        'duration' => 10104
    ],
    'sections' => [
        [
            'name'     => 'section-name',
            'start'    => 10,
            'duration' => 154,
            'memory'   => 17431234,
            'category' => 'handle-request',
            'category-color' => 'green'
        ],
        // Rest of sections...
    ],
    'stops' => [
        [
            'name'     => 'some event',
            'start'    => 20,
            'duration' => 30,
            'memory'   => 17431234,
            'category' => null,
            'category-color' => null,
            'section'  => 'section2'
        ],
        // Rest of stops...
    ]
]
```

TimeLine drawing - Preview
--------------------------

[](#timeline-drawing---preview)

Source data returned from this library can be used to draw the Time Line of execution. Please find dedicated JavaScript timeline drawer here: [requtize/timeline-drawer](https://github.com/requtize/timeline-drawer#requtizecode-timer-integration).

Licence
=======

[](#licence)

This code is licensed under MIT License.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4bfd9944fd280439bc784ca32c0b7768f6683af18369ea67deea146b527a0d68?d=identicon)[eugeneuk](/maintainers/eugeneuk)

---

Top Contributors

[![Mediaessence](https://avatars.githubusercontent.com/u/262103130?v=4)](https://github.com/Mediaessence "Mediaessence (12 commits)")[![eugeneuk](https://avatars.githubusercontent.com/u/89607070?v=4)](https://github.com/eugeneuk "eugeneuk (4 commits)")

### Embed Badge

![Health badge](/badges/eugeneuk-code-timer/health.svg)

```
[![Health](https://phpackages.com/badges/eugeneuk-code-timer/health.svg)](https://phpackages.com/packages/eugeneuk-code-timer)
```

PHPackages © 2026

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