PHPackages                             ayesh/php-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. ayesh/php-timer

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

ayesh/php-timer
===============

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

v2.2.0(5y ago)22226.4k↓20.1%2[1 PRs](https://github.com/Ayesh/php-timer/pulls)11MITPHPPHP ^7.3 || ^8.0CI failing

Since Feb 12Pushed 1y ago4 watchersCompare

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

READMEChangelogDependencies (2)Versions (21)Used By (11)

PHP Timer
=========

[](#php-timer)

[![Latest Stable Version](https://camo.githubusercontent.com/529b009025d9f9ea752c9b62951c232ce65226ac7ca1de9f9fdab369e7c7e418/68747470733a2f2f706f7365722e707567782e6f72672f61796573682f7068702d74696d65722f762f737461626c65)](https://packagist.org/packages/ayesh/php-timer) [![License](https://camo.githubusercontent.com/736948d02ed50db3bfd37543632249b8de344217d643af7248be3fbd5a02fee1/68747470733a2f2f706f7365722e707567782e6f72672f61796573682f7068702d74696d65722f6c6963656e7365)](https://packagist.org/packages/ayesh/php-timer) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/2e787b6033f2f98f5f89096398d8cf04fd090088489eb0728b5874347fce6e0f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f41796573682f7068702d74696d65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Ayesh/php-timer/?branch=master) [![CI](https://github.com/Ayesh/php-timer/workflows/CI/badge.svg)](https://github.com/Ayesh/php-timer/actions) [![codecov](https://camo.githubusercontent.com/cda97ab38e6ab925d936be88b29d3f275ed2c157ed52475ef7dacacff947d6eb/68747470733a2f2f636f6465636f762e696f2f67682f41796573682f7068702d74696d65722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Ayesh/php-timer) [![Too many badges](https://camo.githubusercontent.com/aadaf5fc1f58bb564077e5397e6ae97055ed8d0dff536fd6ebac145ebb50d422/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d746f6f5f6d616e792d627269676874677265656e2e7376673f7374796c653d746f6f6d616e79266c6162656c3d626164676573)](https://github.com/Ayesh/php-timer)

Synopsis
--------

[](#synopsis)

A helper class to calculate how long a particular task took.

This class is similar to phpunit/php-timer, but not a fork, nor mimic its functionality.

- Multiple timers by a given key.
- Read the current time elapsed without stopping the timer.
- Stop the timer, and continue from where it left (stopwatch).
- Dead simple API with only 4 static methods.
- 100% unit test coverage.
- Gets you precise time in milliseconds (with options to convert to seconds)
- Individual `Stopwatch` class for serialization and other use cases.

Prerequisites
-------------

[](#prerequisites)

- PHP 8.2 or later.

Installing
----------

[](#installing)

The simplest way would be to install using [composer](https://getcomposer.org).

```
    composer require ayesh/php-timer
```

Usage
-----

[](#usage)

It is pretty simple to use the timer, with all methods being static, and allowing only 4 methods.

#### Start timer

[](#start-timer)

```
