https://github.com/ayesh/php-timer
A stop-watch and timer with start/stop/pause features and minimal human-friendly formatting.
https://github.com/ayesh/php-timer
php php-timer timer
Last synced: 9 months ago
JSON representation
A stop-watch and timer with start/stop/pause features and minimal human-friendly formatting.
- Host: GitHub
- URL: https://github.com/ayesh/php-timer
- Owner: Ayesh
- License: mit
- Created: 2017-02-12T02:36:49.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-02-02T11:03:20.000Z (about 1 year ago)
- Last Synced: 2025-06-23T02:14:49.315Z (9 months ago)
- Topics: php, php-timer, timer
- Language: PHP
- Homepage:
- Size: 118 KB
- Stars: 22
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Timer
[](https://packagist.org/packages/ayesh/php-timer) [](https://packagist.org/packages/ayesh/php-timer) [](https://scrutinizer-ci.com/g/Ayesh/php-timer/?branch=master) [](https://github.com/Ayesh/php-timer/actions) [](https://codecov.io/gh/Ayesh/php-timer) [](https://github.com/Ayesh/php-timer)
## 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
- PHP 8.2 or later.
## Installing
The simplest way would be to install using [composer](https://getcomposer.org).
```bash
composer require ayesh/php-timer
```
## Usage
It is pretty simple to use the timer, with all methods being static, and allowing only 4 methods.
#### Start timer
```php
";
echo Timer::read('laps', Timer::FORMAT_SECONDS); // 2 seconds (1 + 1)
````
## Development and tests
All issues are PRs are welcome. Travis CI and PHPUnit tests are included. If you are adding new features, please make sure to add the test coverage.
## Credits
By [Ayesh Karunaratne](https://aye.sh) and [contributors](https://github.com/Ayesh/php-timer/graphs/contributors).
kthxbye