PHPackages                             kkiernan/php-stopwatch - 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. kkiernan/php-stopwatch

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

kkiernan/php-stopwatch
======================

A simple stopwatch in PHP

v2.2(7y ago)01.7k↓100%[1 issues](https://github.com/kkiernan/php-stopwatch/issues)MITPHP

Since Dec 5Pushed 7y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

PHP Stopwatch
=============

[](#php-stopwatch)

A simple stopwatch in PHP.

[![StyleCI](https://camo.githubusercontent.com/97f96918338ae9d5044b28d423431e447269364c83122f0c0c7517b91f8b29c4/68747470733a2f2f7374796c6563692e696f2f7265706f732f37353633393030362f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/75639006)

Contents
--------

[](#contents)

- [Installation](#installation)
- [Available Methods](#available-methods)
- [Basic Usage](#basic-usage)
- [Laps](#laps)

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

[](#installation)

Install the package using composer.

```
composer require kkiernan/php-stopwatch
```

Available Methods
-----------------

[](#available-methods)

- `start()`
- `stop()`
- `lap()`
- `elapsed()`

Basic Usage
-----------

[](#basic-usage)

```
use Kiernan\Stopwatch;

require dirname(__DIR__). '/vendor/autoload.php';

$stopwatch = new Stopwatch();

$stopwatch->start();

usleep(1500000);

$stopwatch->stop();

echo "Script executed in {$stopwatch->elapsed()} seconds";
```

The above example prints the following output:

```
Script executed in 3.0002250671387 seconds

```

Laps
----

[](#laps)

```
use Kiernan\Stopwatch;

require dirname(__DIR__). '/vendor/autoload.php';

$stopwatch = new Stopwatch();

$stopwatch->start();
sleep(1);
$stopwatch->lap();
sleep(2);
$stopwatch->lap();
sleep(1);
$stopwatch->lap();
$stopwatch->stop();

print_r($stopwatch->laps);
```

The above example prints the following output:

```
Array
(
    [0] => Kiernan\Lap Object
        (
            [start:protected] => 1542305179.9815
            [duration:protected] => 1.0043249130249
            [name:protected] =>
        )

    [1] => Kiernan\Lap Object
        (
            [start:protected] => 1542305181.9823
            [duration:protected] => 2.0006990432739
            [name:protected] =>
        )

    [2] => Kiernan\Lap Object
        (
            [start:protected] => 1542305182.9823
            [duration:protected] => 1.0000500679016
            [name:protected] =>
        )

)
```

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Total

4

Last Release

2732d ago

Major Versions

v1.0 → v2.02018-11-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/99d8fa03037957d5ebd061dade4a624bc2b7b324cef2c955f5a8dcb728d97ab1?d=identicon)[kkiernan](/maintainers/kkiernan)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kkiernan-php-stopwatch/health.svg)

```
[![Health](https://phpackages.com/badges/kkiernan-php-stopwatch/health.svg)](https://phpackages.com/packages/kkiernan-php-stopwatch)
```

###  Alternatives

[formapro/pvm

The library provides us with a frame to build a workflow or a business process such as BPMN. Could execute tasks in parallel or delayed tasks

36823.8k](/packages/formapro-pvm)

PHPackages © 2026

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