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

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

almasmurad/stopwatch
====================

Component for measuring code execution time

0.4.4(2y ago)02MITPHPPHP ^7.0

Since Feb 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/uhamurad/stopwatch)[ Packagist](https://packagist.org/packages/almasmurad/stopwatch)[ RSS](/packages/almasmurad-stopwatch/feed)WikiDiscussions 0.4.x Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (16)Used By (0)

Stopwatch
=========

[](#stopwatch)

PHP tool that measures code execution time.

[README in Russian](docs/ru/README.md)

Usage
-----

[](#usage)

```
// create Stopwatch
$stopwatch = new Almasmurad\Stopwatch\Stopwatch();

// start measuring the first step
$stopwatch->start('code section #1');
//...

// start measuring the second step
$stopwatch->step('code section #2');
//...

// start measuring the third step
$stopwatch->step('code section #3');
//...

// finish measuring
$stopwatch->finish();

// output the report
$stopwatch->report();
```

As a result, the following report gets into the standard output:

```
 Start           | 06:55:14.123
-----------------|--------------
 code section #1 |      0.198 s
 code section #2 |      0.209 s
 code section #3 |      1.200 s
-----------------|--------------
 Summary         |      1.607 s

```

Minimal Usage
-------------

[](#minimal-usage)

```
$stopwatch = new Almasmurad\Stopwatch\Stopwatch();

//... (measured code)

$stopwatch->report();
```

As a result, the following report gets into the standard output:

```
 Start   | 06:55:14.123
---------|--------------
 Summary |      0.198 s

```

### Output Report to File

[](#output-report-to-file)

```
$stopwatch->reportToFile(__DIR__.'/report.txt');
```

Report will be written to a file, and nothing will get into the standard output. If the file already exists, the report will replace its contents. In order for the report to append the contents of the file, use another method:

```
$stopwatch->reportToFileInAppendMode(__DIR__.'/report.txt');
```

### Access to the Report Components

[](#access-to-the-report-components)

Instead of outputting the report to a standard stream or file, you can access its components:

```
// getting the report object
$report = $stopwatch->getReport();

// general indicators
$start   = $report->getStart()->getTimestamp();   // stopwatch start time
$finish  = $report->getFinish()->getTimestamp();  // stopwatch finish time
$elapsed = $report->getElapsed()->getSeconds();   // time of the entire stopwatch operation

// indicators of first code section
$step1_start   = $report->getStepByIndex(0)->getStart()->getTimestamp();
$step1_finish  = $report->getStepByIndex(0)->getFinish()->getTimestamp();
$step1_elapsed = $report->getStep('code section #1')->getElapsed()->getSeconds();

// all of code sections
foreach ($report->getSteps() as $step){
    //...
}
```

You can read more about the report object in the section '[Report object](Report/ReportObject.md)'

Learn More
----------

[](#learn-more)

- [Notices and Erroneous Situations](docs/en/Notices.md)
- [Report Object](docs/en/Report/ReportObject.md)
- [Reporting customization](docs/en/Report/ReportingCustomization.md)
- [About the Development](docs/en/Development.md)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

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

Recently: every ~0 days

Total

15

Last Release

742d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d7305f84f0b45d2ac323b8927155cf565ff7fbab3f9ff0b24588a2dd269fb95?d=identicon)[almasmurad](/maintainers/almasmurad)

---

Top Contributors

[![uhamurad](https://avatars.githubusercontent.com/u/4056980?v=4)](https://github.com/uhamurad "uhamurad (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[codenco-dev/nova-grid-system

A Laravel Nova tool to have a grid system

80300.1k](/packages/codenco-dev-nova-grid-system)[mageplaza/module-share-cart

Magento 2 Share Cart extension

12182.8k2](/packages/mageplaza-module-share-cart)

PHPackages © 2026

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