PHPackages                             ershov-ilya/timer.class.php - 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. ershov-ilya/timer.class.php

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

ershov-ilya/timer.class.php
===========================

Multi timer with tree-structured dependences

v1.3.1(10y ago)018MITPHP

Since Dec 8Pushed 10y ago2 watchersCompare

[ Source](https://github.com/ershov-ilya/timer.class.php)[ Packagist](https://packagist.org/packages/ershov-ilya/timer.class.php)[ RSS](/packages/ershov-ilya-timerclassphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/85434817ee127b9e9cdd56a5a52071f9cdd39e27704f4f71d8c8345fbddaca89/68747470733a2f2f706f7365722e707567782e6f72672f657273686f762d696c79612f74696d65722e636c6173732e7068702f762f737461626c65)](https://packagist.org/packages/ershov-ilya/timer.class.php)[![Total Downloads](https://camo.githubusercontent.com/45a2f75f14bf90f2ed00c3127ac2cf749e5b3daef7b5883f537e485296d0481b/68747470733a2f2f706f7365722e707567782e6f72672f657273686f762d696c79612f74696d65722e636c6173732e7068702f646f776e6c6f616473)](https://packagist.org/packages/ershov-ilya/timer.class.php)[![Latest Unstable Version](https://camo.githubusercontent.com/28b35e7ffec38eb768c9d83cc84daf65a75425963e923abb5d4f514a1a8f842e/68747470733a2f2f706f7365722e707567782e6f72672f657273686f762d696c79612f74696d65722e636c6173732e7068702f762f756e737461626c65)](https://packagist.org/packages/ershov-ilya/timer.class.php)[![License](https://camo.githubusercontent.com/edcd4d6eda9dda69dff083b9dd024d0b68ffbdcdffdde049122dc06340d5271d/68747470733a2f2f706f7365722e707567782e6f72672f657273686f762d696c79612f74696d65722e636c6173732e7068702f6c6963656e7365)](https://packagist.org/packages/ershov-ilya/timer.class.php)

Multi timer
===========

[](#multi-timer)

with tree-structured dependences

### Simpe code example

[](#simpe-code-example)

```
require_once('timer.class.php');
$timer=new Timer();

// Default timer (unnamed)
$timer->start();
usleep(200000);
$timer->stop();
print $timer();

// Named timer
$timer->start('mysql');
usleep(300000);
print $timer('mysql'); // Get value before timer stop - works OK too
$timer->stop('mysql');

// Sum of gaps
$timer->start('gap');
usleep(100000);
$timer->stop('gap');
$timer->start('gap');
usleep(200000);
$timer->stop('gap');
$timer->start('gap');
usleep(300000);
$timer->stop('gap');
// Get sum of all gaps
print $timer('gap'); // returns ~ 0.6 (sec)

print_r($timer->data()); // Results array
print $timer; // Print report

```

This class can create timers with dependencies, counters will be stored in a tree structure. Start and stop timers can be any number of times, in the end it will show the sum of time gaps. \_\_invoke function returns current time gaps sum, with NO stop it.

So here are advanced methods:

```
$timer->start('mysql.sql.query.response.parsing', true); // Second parameter in "true" says to start all parent-timers
$timer->stopTree('mysql'); // Stop timers tree "mysql"

```

### Advanced code example

[](#advanced-code-example)

```
require_once('timer.class.php');
$timer=new Timer(array(
'debug'=>true
));
$timer->start('mysql.sql.query.response.parsing',true);
$timer->start('postgres.sql.query.response.parsing');
usleep(200000);
print_r($timer->data());
print $timer;
$timer->start('file.read');
$timer->stopTree('mysql');
usleep(300000);
print_r($timer->data());

```

The class is configurable via config array, which can be passed as parameter of class constructor

```
$config=array(
    'query_delimiter'   =>  '.',
    'output_delimiter'  =>  '=',
    'add_children_time' => true,
    'debug'             => false
);
$timer=new Timer($config);

```

### PHPUnit test

[](#phpunit-test)

```
phpunit --repeat 200 --bootstrap dist/timer.class.php tests\TimerTest.php

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

3

Last Release

3859d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3964147?v=4)[ILYA ERSHOV](/maintainers/ershov-ilya)[@ershov-ilya](https://github.com/ershov-ilya)

---

Top Contributors

[![ershov-ilya](https://avatars.githubusercontent.com/u/3964147?v=4)](https://github.com/ershov-ilya "ershov-ilya (34 commits)")

### Embed Badge

![Health badge](/badges/ershov-ilya-timerclassphp/health.svg)

```
[![Health](https://phpackages.com/badges/ershov-ilya-timerclassphp/health.svg)](https://phpackages.com/packages/ershov-ilya-timerclassphp)
```

PHPackages © 2026

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