-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the official documentation for initphp/performance-meter — a zero-dependency, single-class PHP profiler for measuring elapsed time and memory usage between named checkpoints.
The entire public surface is two types:
| Type | Purpose |
|---|---|
PerformanceMeter |
Static class. Records named checkpoints and computes time / memory deltas between them. |
PointerNotFoundException |
Thrown when you reference a checkpoint name that was never recorded. |
composer require initphp/performance-meteruse InitPHP\PerformanceMeter\PerformanceMeter;
PerformanceMeter::setPointer('start');
usleep(50_000);
PerformanceMeter::setPointer('end');
echo PerformanceMeter::elapsedTime('start', 'end'), " seconds\n";
echo PerformanceMeter::memoryUsage('start', 'end'), " delta\n";A tool for probe-style measurements in small PHP programs. Drop a setPointer() call into your code, drop another later, ask for the delta. Nothing more.
It is intentionally minimal: one class, six static methods (plus one alias), no configuration, no instances, no dependencies. The intended audience is people writing one-off benchmarks, CLI tools, cron jobs, library examples, and reproducer scripts — places where the friction of installing and learning a "real" profiler is the whole reason the measurement never gets added.
It is not an application profiler. It does not draw flame graphs, doesn't integrate with APM vendors, doesn't track nested sections, periods, or categories, and doesn't isolate measurements per request or per scope. The single static registry that powers the API is a deliberate trade-off: it keeps probe code to a single line at the cost of giving every measurement the same global namespace.
See Use Cases & Comparison for a side-by-side with symfony/stopwatch, Xdebug, Blackfire, Tideways, SPX, OpenTelemetry, and friends — and clear pointers on when this package is the wrong tool.
- New to the package? Read Installation, then Quick Start.
- Want the mental model? Read Concepts. It is short and explains every surprise you might hit.
- Looking for a specific method's behaviour? API Reference lists every method with parameters, return types, and edge cases.
- Want copy-pasteable examples? Recipes collects real-world patterns.
- Upgrading from v1.x? Migration Guide walks through every behavioural change.
- Requires PHP 8.1+
- Zero runtime dependencies
- 100 % line / method / class test coverage
- CI runs on PHP 8.1 → 8.4 with both highest and lowest installable dependencies
- Static analysis: PHPStan
level: max, clean - Coding standard: PSR-12 + PHP 8.1 migration set, enforced in CI
initphp/performance-meter · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Changelog · Contributing · Security Policy
Getting Started
Reference
Recipes
Migration & Help