PHPackages                             shawnlindstrom/laravel-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. shawnlindstrom/laravel-timer

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

shawnlindstrom/laravel-timer
============================

Simple high-resolution monotonic timer

v0.2.0(2mo ago)133MITPHPPHP ^8.3CI failing

Since Dec 4Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/shawnlindstrom/laravel-timer)[ Packagist](https://packagist.org/packages/shawnlindstrom/laravel-timer)[ Docs](https://github.com/shawnlindstrom/laravel-timer)[ RSS](/packages/shawnlindstrom-laravel-timer/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (6)Versions (7)Used By (0)

Laravel Timer
=============

[](#laravel-timer)

[![Packagist](https://camo.githubusercontent.com/a5f029c90c7c571abf24d7bcad2a92256b9c380f52a1de14247e416ce0c9402e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736861776e6c696e647374726f6d2f6c61726176656c2d74696d65722e737667)](https://camo.githubusercontent.com/a5f029c90c7c571abf24d7bcad2a92256b9c380f52a1de14247e416ce0c9402e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736861776e6c696e647374726f6d2f6c61726176656c2d74696d65722e737667)[![Packagist](https://camo.githubusercontent.com/f26c698101bb68abad575b0ab1a1f580f6184e0910b2955da50412e0ffa8d3fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736861776e6c696e647374726f6d2f6c61726176656c2d74696d65722e737667)](https://camo.githubusercontent.com/f26c698101bb68abad575b0ab1a1f580f6184e0910b2955da50412e0ffa8d3fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736861776e6c696e647374726f6d2f6c61726176656c2d74696d65722e737667)[![Tests](https://camo.githubusercontent.com/3ab4882a1b7d64e5eb5168ad0b0b9cdfd53f59f114ee5f727958504214a5789c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e737667)](https://camo.githubusercontent.com/3ab4882a1b7d64e5eb5168ad0b0b9cdfd53f59f114ee5f727958504214a5789c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e737667)[![PHP](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)[![Laravel](https://camo.githubusercontent.com/b72e0aa3b09f6ee9f1cd47f19792a8204408312803c6b277768a5d2c99ffd60c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e782d7265642e737667)](https://camo.githubusercontent.com/b72e0aa3b09f6ee9f1cd47f19792a8204408312803c6b277768a5d2c99ffd60c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e782d7265642e737667)

A modern, high-resolution monotonic timer for Laravel applications. Perfect for benchmarking, performance measurement, and precise timing operations.

Features
--------

[](#features)

- 🚀 High-resolution timing using `hrtime()`
- ⏱️ Multiple time units (seconds, milliseconds, microseconds, nanoseconds)
- 🎯 Type-safe with PHP 8.3+ enums
- 📊 Laravel service provider &amp; facade support
- ✅ 90%+ test coverage
- 🔒 Strict types throughout

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 12.x

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

[](#installation)

Install via Composer:

```
composer require shawnlindstrom/laravel-timer
```

The package will automatically register itself via Laravel's package discovery.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use shawnlindstrom\LaravelTimer\Timer;
use shawnlindstrom\LaravelTimer\TimeUnit;

$timer = new Timer;
$timer->start();

// Your code to benchmark
sleep(2);

$timer->stop();

echo $timer->elapsed(); // Returns: 2 (default is seconds)
```

### Different Time Units

[](#different-time-units)

```
$timer = new Timer;
$timer->start();

// Your code here...

$timer->stop();

// Get elapsed time in different units
$seconds = $timer->elapsed(TimeUnit::SECOND);           // 2
$microseconds = $timer->elapsed(TimeUnit::MICROSECOND); // 2000
$milliseconds = $timer->elapsed(TimeUnit::MILLISECOND); // 2000000
$nanoseconds = $timer->elapsed(TimeUnit::NANOSECOND);   // 2000000000
```

### Using the Facade

[](#using-the-facade)

```
use shawnlindstrom\LaravelTimer\TimerFacade as Timer;
use shawnlindstrom\LaravelTimer\TimeUnit;

Timer::start();

// Your code to benchmark...

Timer::stop();

echo Timer::elapsed(TimeUnit::MICROSECOND);
```

### Alias Usage

[](#alias-usage)

If you prefer, you can use the pre-configured alias:

```
use Timer;
use shawnlindstrom\LaravelTimer\TimeUnit;

Timer::start();
// Your code...
Timer::stop();

echo Timer::elapsed(TimeUnit::MILLISECOND);
```

### Reusable Measurements

[](#reusable-measurements)

The timer can be reused for multiple measurements:

```
$timer = new Timer;

// First measurement
$timer->start();
performTask1();
$timer->stop();
$time1 = $timer->elapsed();

// Second measurement
$timer->start();
performTask2();
$timer->stop();
$time2 = $timer->elapsed();
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Generate code coverage report:

```
composer test:coverage
```

Run static analysis:

```
composer analyse
```

Format code:

```
composer format
```

Change Log
----------

[](#change-log)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Shawn Lindstrom](https://github.com/shawnlindstrom)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE.md](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance84

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

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

Recently: every ~658 days

Total

6

Last Release

81d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dcb1398898c1e1c1711397a3151972e825d8473a428472cf3d46295610d4a000?d=identicon)[shawnlindstrom](/maintainers/shawnlindstrom)

---

Top Contributors

[![shawnlindstrom](https://avatars.githubusercontent.com/u/6542662?v=4)](https://github.com/shawnlindstrom "shawnlindstrom (10 commits)")

---

Tags

laravelperformancetimerbenchmarklaravel-timer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/shawnlindstrom-laravel-timer/health.svg)

```
[![Health](https://phpackages.com/badges/shawnlindstrom-laravel-timer/health.svg)](https://phpackages.com/packages/shawnlindstrom-laravel-timer)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M686](/packages/barryvdh-laravel-ide-helper)[webpatser/laravel-uuid

Laravel integration for webpatser/uuid - High-performance drop-in UUID replacements (15% faster than Ramsey). Provides Str macros, HasUuids trait, facades, and casts. RFC 4122/9562 compliant.

1.8k17.3M128](/packages/webpatser-laravel-uuid)[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)[krisawzm/critical-css

A Laravel package for generating and using inline critical-path CSS.

4714.2k2](/packages/krisawzm-critical-css)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)

PHPackages © 2026

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