PHPackages                             drealecs/time-benchmark - 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. drealecs/time-benchmark

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

drealecs/time-benchmark
=======================

Library for timing execution and benchmarking

v1.1.1(2y ago)0791[1 PRs](https://github.com/drealecs/time-benchmark/pulls)1MITPHPPHP &gt;=8.1CI failing

Since May 28Pushed 2y ago2 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (5)Used By (1)

drealecs/time-benchmark
=======================

[](#drealecstime-benchmark)

Library for timing execution and benchmarking

Stopwatch
---------

[](#stopwatch)

An instance of the stopwatch can be created with the static methods:

```
$stopwatch = Stopwatch::create();
```

or

```
$stopwatch = Stopwatch::createStarted();
```

As the name suggests `createStarted()` method is also starting the stopwatch. A not started stopwatch can be started using

```
$stopwatch->start();
```

When a stopwatch is started, it can be stopped with

```
$stopwatch->stop();
```

While capturing time, `hrtime()` is used for the best efficiency. On 32-bit runtimes there might be some decimal losses due to float php precision limit but only on microsecond decimals level. The methods `start()` and `stop()` are fast and the calculation of the difference is done when calling the methods:

```
$seconds = $stopwatch->getElapsedSeconds();
$milliseconds = $stopwatch->getElapsedMilliseconds();
$microseconds = $stopwatch->getElapsedMicroseconds();
```

There are also three stopwatch status methods that can be used

```
$stopwatch->wasStarted();
$stopwatch->isRunning();
$stopwatch->wasStopped();
```

Another functionality also included is related to steps (or laps). When a stopwatch is running, steps can be marked without affecting the stopwatch status with:

```
$stopwatch->step($stepName);
```

$stepName is the name of the step and must not be reused for the same stopwatch.

The number of steps can be retrieved with

```
$stopwatch->getStepsNumber();
```

There are three methods for retrieving the time difference between start and each of the steps. The result is an array indexed by the step name.

```
$seconds = $stopwatch->getElapsedStepsSeconds();
$milliseconds = $stopwatch->getElapsedStepsMilliseconds();
$microseconds = $stopwatch->getElapsedStepsMicroseconds();
```

There is support for pausing the stopwatch. The methods to do this are:

```
$stopwatch->pause();
$stopwatch->resume();
```

Pausing and resuming are as fast as possible, and the calculation is done within the `getElapsed*` methods.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity75

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

Total

3

Last Release

934d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.4

v1.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8714fa223d32c91d96ba5aededaea9dba9b395eb7574732e5964c280d2b5efaf?d=identicon)[drealecs](/maintainers/drealecs)

---

Top Contributors

[![drealecs](https://avatars.githubusercontent.com/u/209984?v=4)](https://github.com/drealecs "drealecs (36 commits)")

---

Tags

timerbenchmark

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drealecs-time-benchmark/health.svg)

```
[![Health](https://phpackages.com/badges/drealecs-time-benchmark/health.svg)](https://phpackages.com/packages/drealecs-time-benchmark)
```

###  Alternatives

[devster/ubench

Micro PHP library for benchmarking

5701.0M29](/packages/devster-ubench)[dragon-code/benchmark

Simple comparison of code execution speed between different options

11934.7k5](/packages/dragon-code-benchmark)[ayesh/php-timer

High-resolution and monotonic stop-watch for all your needs. Supports timer start, pause, resume, stop, read, and minimal conversion.

22226.4k11](/packages/ayesh-php-timer)[christophrumpel/artisan-benchmark

Benchmark Artisan Commands

17966.6k](/packages/christophrumpel-artisan-benchmark)[icecave/chrono

A date &amp; time library that is decoupled from the system clock.

54188.9k7](/packages/icecave-chrono)

PHPackages © 2026

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