sebastianbergmann

sebastianbergmann/php-timer

PHP BSD-3-Clause Dev Tools

Utility class for timing

7.7k stars
63 forks
recent
GitHub

7.7k

Stars

63

Forks

1

Open issues

12

Contributors

9.0.0 06 Feb 2026

AI Analysis

php-timer is a lightweight utility class for measuring execution time and resource consumption in PHP applications, factored out from PHPUnit as a standalone component. It serves developers who need precise timing instrumentation, particularly those working with testing frameworks, performance monitoring, and development workflows. While it has significant adoption (7,743 stars), it is a specialized timing library best suited for developers and CI/CD pipelines rather than end-user applications.

Dev Tools Library Discovery value: 3/10
Documentation 8/10
Activity 9/10
Community 8/10
Code quality 9/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

timing-utility performance-measurement phpunit-component resource-monitoring developer-utility
Actively maintained Well documented Niche/specialized use case Beginner friendly Production ready
Deep Analysis · Based on README and public signals
2w ago

PHP timing utility extracted from PHPUnit, now a standalone Composer component

php-timer is a small, focused PHP library for measuring execution time and reporting resource usage (time + memory). Originally part of PHPUnit's internals, it was extracted into a standalone package so any PHP project can use it independently. Its primary audience is PHP developers writing test suites, CLI tools, or any code that needs human-readable duration formatting. It is a transitive dependency of PHPUnit, which alone accounts for tens of millions of Composer installs, making its real-world reach enormous even if direct intentional adoption is modest.

Origin

Created in May 2010 by Sebastian Bergmann as part of the PHPUnit ecosystem. Factored out of PHPUnit's core to follow the single-responsibility principle and allow independent reuse. Now on a stable major version cadence alongside PHPUnit releases.

Growth

Star growth is essentially flat on its own (0 in the last 7 days), which is expected for a utility with this profile. Its true growth metric is Packagist download count, not GitHub stars — it inherits massive install volume as a required dependency of PHPUnit, one of the most-installed PHP packages globally. Stars (~7,700) likely reflect passive discovery by developers exploring PHPUnit's dependency tree rather than organic interest in the library itself.

In production

As a declared dependency of PHPUnit (20k+ stars, industry-standard PHP testing framework), php-timer is installed on effectively every PHP project that runs tests via Composer. Packagist download counts for phpunit/php-timer are in the hundreds of millions historically. This is one of the most-installed PHP packages by volume, even if developers rarely interact with it directly.

Code analysis
Architecture

Appears to be a minimal, object-oriented design with at least two classes: Timer (start/stop with nanosecond precision via hrtime) and ResourceUsageFormatter (formats duration + memory_get_peak_usage output). A Duration value object is returned by stop(), providing unit-conversion methods. Likely has no external dependencies beyond PHP itself.

Tests

A codecov badge is present in the README, indicating automated coverage tracking is in place. Exact coverage percentage is not stated in the README excerpt, but the presence of the badge and CI workflow suggests coverage is actively maintained.

Maintenance

Last push was 2026-06-22, four days before the evaluation date — the project is actively maintained. CI status badge is shown. Given its role as a PHPUnit dependency, maintenance is effectively guaranteed as long as PHPUnit is maintained.

Honest verdict

ADOPT IF: you are building a PHP CLI tool, test framework, or utility that needs clean duration formatting and memory reporting without pulling in a larger dependency. AVOID IF: you need named laps, concurrent timers, or statistical aggregation across many measurements — use symfony/stopwatch or phpbench instead. MONITOR IF: you depend on it transitively through PHPUnit and want to track API changes across major PHPUnit version bumps.

Independent dimensions

Mainstream potential

2/10

Technical importance

4/10

Adoption evidence

9/10

Risks
  • API surface changes with each major PHPUnit version cycle may require updates if used directly rather than transitively.
  • The library solves a narrow problem; if PHP adds a standard timing/duration value object to its stdlib, this package becomes redundant.
  • Very low fork count (63) suggests minimal external contribution, meaning long-term maintenance is concentrated in a single maintainer.
  • Zero stars gained in the last 7 days reflects no organic discovery growth — community awareness outside the PHPUnit ecosystem is limited.
  • Projects that use it only as a transitive dependency may not notice breaking changes if they accidentally couple to its API.
Prediction

Will remain stable and well-maintained indefinitely as a PHPUnit ecosystem component. No significant standalone growth expected; its value is as reliable infrastructure, not an expanding product.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

PHP
100%

Information

Language
PHP
License
BSD-3-Clause
Last updated
3w ago
Created
197mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Open pull requests

No open pull requests.

Similar repos

sebastianbergmann

sebastianbergmann/phpunit

PHPUnit is the de facto standard unit testing framework for PHP, implementing...

20k PHP Dev Tools
sebastianbergmann

sebastianbergmann/environment

This PHP library provides utilities for detecting and handling runtime-specific...

6.8k PHP Dev Tools
sebastianbergmann

sebastianbergmann/comparator

This component provides functionality to compare PHP values for equality, with...

7.1k PHP Dev Tools
sebastianbergmann

sebastianbergmann/php-code-coverage

php-code-coverage is a specialized PHP library for collecting, processing, and...

8.9k PHP Dev Tools
sebastianbergmann

sebastianbergmann/diff

A PHP diff implementation factored out of PHPUnit into a standalone component....

7.7k PHP Dev Tools
vs. alternatives
symfony/stopwatch

Symfony's Stopwatch component offers named laps, sections, and event categorization — more featureful for profiling multiple named operations. php-timer is simpler and lighter, focused on a single timing context plus memory reporting.

spatie/once (and similar micro-utilities)

Not a direct competitor; mentioned only to note that the PHP ecosystem has many micro-utilities. php-timer occupies a well-defined, non-overlapping niche.

PHP's native microtime()/hrtime()

php-timer wraps these with human-readable formatting and a Duration value object. Developers who only need raw timestamps don't need this library, but the formatting layer adds real convenience for CLI/test output.

phpbench/phpbench

PHPBench is a full benchmarking framework with statistical analysis, output formats, and reporting. php-timer is not a benchmarking tool — it is a lightweight timing primitive for use inside other tools.