PHPackages                             loophp/phpspec-time - 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. loophp/phpspec-time

AbandonedArchivedLibrary

loophp/phpspec-time
===================

A PHPSpec extension providing matchers for measuring time in tests.

1.1.1(5y ago)1150[1 PRs](https://github.com/loophp/phpspec-time/pulls)2MITPHPPHP &gt;= 7.4

Since Oct 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/loophp/phpspec-time)[ Packagist](https://packagist.org/packages/loophp/phpspec-time)[ Fund](https://www.paypal.me/drupol)[ GitHub Sponsors](https://github.com/drupol)[ RSS](/packages/loophp-phpspec-time/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (8)Versions (6)Used By (2)

[![Latest Stable Version](https://camo.githubusercontent.com/743768c150d8828aadb6343fbdc1ec389bfbeee8131fc966f13733193103ff87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6f7068702f706870737065632d74696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/phpspec-time)[![GitHub stars](https://camo.githubusercontent.com/40bce5a9f1a1a51ee8cf38b69756fc95345fcdd924e625ffe76997a731bbab36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6c6f6f7068702f706870737065632d74696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/phpspec-time)[![Total Downloads](https://camo.githubusercontent.com/2fd992914da2291afbc710ede75df5cd00b879c8b8c8ed3562f0c0c3cfaa6a4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6f7068702f706870737065632d74696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/phpspec-time)[![GitHub Workflow Status](https://camo.githubusercontent.com/cdfea75eab276cf56777a0d94bb14652423430c4c62d28e999d3e1565294fec5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6c6f6f7068702f706870737065632d74696d652f436f6e74696e756f7573253230496e746567726174696f6e3f7374796c653d666c61742d737175617265)](https://github.com/loophp/phpspec-time/actions)[![Scrutinizer code quality](https://camo.githubusercontent.com/940ce83b3fbf944595915d559d260d597a762f65071e26dd75f625ca6f0e5f60/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6c6f6f7068702f706870737065632d74696d652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/loophp/phpspec-time/?branch=master)[![Type Coverage](https://camo.githubusercontent.com/be6a2b4a583a9896ce218a46dbffb92f644f8d99632e315006f0d442763ab7c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f7374796c653d666c61742d73717561726526636f6c6f723d636f6c6f72266c6162656c3d54797065253230636f7665726167652671756572793d6d6573736167652675726c3d687474707325334125324625324673686570686572642e6465762532466769746875622532466c6f6f706870253246706870737065632d74696d65253246636f766572616765)](https://shepherd.dev/github/loophp/phpspec-time)[![Code Coverage](https://camo.githubusercontent.com/26500d302ec2ae8f62ddc48d74450fd812d602c6faebb4caedcd4f7c50180c24/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c6f6f7068702f706870737065632d74696d652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/loophp/phpspec-time/?branch=master)[![License](https://camo.githubusercontent.com/cf936aa6e3254e8e6c52c833ae22acf69e4c9c852b18c6d892893ab568e029e5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f6f7068702f706870737065632d74696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/phpspec-time)[![Donate!](https://camo.githubusercontent.com/a71f45de7e408be2477113d166e9ee94c90bbf814a1373fd154aa5b6652302de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d4769746875622d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/sponsors/drupol)[![Donate!](https://camo.githubusercontent.com/cd335a74177c62640acfbb95db4f1848f818606fdf17dc36aed4eef93061dc10/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d50617970616c2d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://www.paypal.me/drupol)

PHPSpec Time
============

[](#phpspec-time)

A [PHPSpec](http://www.phpspec.net/) extension providing matchers for measuring time in tests.

New matchers:

- `shouldTakeLessThan(float $timeUnit)`
- `shouldTakeMoreThan(float $timeUnit)`
- `shouldTakeInBetween(float $fromTimeUnit, float $toTimeUnit)`

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

[](#installation)

`composer require loophp/phpspec-time`

Usage
-----

[](#usage)

Add the extension to the phpspec configuration file:

```
extensions:
    loophp\phpspectime\Extension: ~
```

By default, the time unit is in `second`, however other units are available:

- `nanosecond`
- `microsecond`
- `millisecond`
- `second`
- `minute`
- `hour`
- `day`
- `week`

If you want to change the time unit edit the extension configuration as such:

```
extensions:
    loophp\phpspectime\Extension:
        timeunit: nanosecond
```

In your tests, you'll have now access to the following new matchers:

```
    $this
        ->shouldTakeMoreThan(10)
        ->during('method');

    $this
        ->shouldNotTakeMoreThan(10)
        ->during('method');

    $this
        ->shouldTakeLessThan(10)
        ->during('method');

    $this
        ->shouldNotTakeLessThan(10)
        ->during('method');

    $this
        ->shouldTakeInBetween(3.0, 3.2)
        ->during('method');

    $this
        ->shouldNotTakeInBetween(3.0, 3.2)
        ->during('method');
```

Code quality, tests and benchmarks
----------------------------------

[](#code-quality-tests-and-benchmarks)

Every time changes are introduced into the library, [Github](https://github.com/loophp/phpspec-time/actions) run the tests.

The library has tests written with [PHPSpec](http://www.phpspec.net/). Feel free to check them out in the `spec` directory. Run `composer phpspec` to trigger the tests.

Before each commit some inspections are executed with [GrumPHP](https://github.com/phpro/grumphp), run `composer grumphp` to check manually.

The quality of the tests is tested with [Infection](https://github.com/infection/infection) a PHP Mutation testing framework, run `composer infection` to try it.

Static analysers are also controlling the code. [PHPStan](https://github.com/phpstan/phpstan) and [PSalm](https://github.com/vimeo/psalm) are enabled to their maximum level.

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

[](#contributing)

Feel free to contribute by sending Github pull requests. I'm quite reactive :-)

If you can't contribute to the code, you can also sponsor me on [Github](https://github.com/sponsors/drupol) or [Paypal](https://www.paypal.me/drupol).

Changelog
---------

[](#changelog)

See [CHANGELOG.md](https://github.com/loophp/phpspec-time/blob/master/CHANGELOG.md) for a changelog based on [git commits](https://github.com/loophp/phpspec-time/commits/master).

For more detailed changelogs, please check [the release changelogs](https://github.com/loophp/phpspec-time/releases).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62% 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 ~71 days

Total

3

Last Release

1874d ago

PHP version history (3 changes)1.0.0PHP &gt;= 7.1.3

1.1.0PHP &gt;= 7.3

1.1.1PHP &gt;= 7.4

### Community

Maintainers

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

---

Top Contributors

[![drupol](https://avatars.githubusercontent.com/u/252042?v=4)](https://github.com/drupol "drupol (31 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (19 commits)")

---

Tags

phpspec-extensionphpspec-extension

###  Code Quality

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/loophp-phpspec-time/health.svg)

```
[![Health](https://phpackages.com/badges/loophp-phpspec-time/health.svg)](https://phpackages.com/packages/loophp-phpspec-time)
```

PHPackages © 2026

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