dragon-code/benchmark
dragon-code/benchmark is a simple PHP benchmarking package for comparing code execution speed across multiple options. Use bench() or Benchmark with named closures and view min, max, avg, and total timings in the console. Install via Composer as a dev dependency.
Architecture fit. dragon-code/benchmark is a single-purpose, framework-agnostic PHP micro-benchmarking library installed as a dev-only Composer dependency (--dev). It has essentially zero architectural footprint: no service provider, no config publishing, no runtime coupling. It fits naturally into the "developer tooling / test harness" layer of a Laravel or plain-PHP codebase and never ships to production. For a TPM, this is a low-blast-radius, opt-in addition.
Integration feasibility. Very high. The fluent API (bench()->compare(...)->toConsole()) and the toData() DTO output make it usable both interactively (developer comparing two implementations) and programmatically (CI assertions). The toAssert() helpers (toBeAvgTime, toBeRegressionTime, etc.) plus the new snapshot/regression feature (4.6.0) mean it can be wired into automated quality gates rather than remaining a manual curiosity. There is no Laravel service provider expected, so "Laravel fit" is really "plain PHP fit that happens to live well inside a Laravel project's test/CI scripts."
Technical risk. Low-to-moderate. Production risk is effectively nil (dev-only). The real risks are measurement validity and sustainability:
0 bytes, so memory-based assertions may be less trustworthy than time-based ones for small payloads.Key questions a TPM should resolve before adoption.
toBeRegressionTime/toBeRegressionMemory trustworthy, and are we willing to pin PHP version + commit .snap files?Stack fit. Drop-in for Laravel and generic PHP projects. Install with composer require dragon-code/benchmark --dev. Works inside CLI scripts, Artisan commands, or PHPUnit/Pest test cases. No production dependency, no autoloading concerns, no impact on deploy artifacts beyond composer.lock dev entries.
Migration path. Purely additive — there is nothing to migrate from. The adoption path is: (1) add as a dev dependency; (2) benchmark one or two known-hot code paths to validate that the output is decision-useful in your environment; (3) if signal is clean, promote selected benchmarks into CI as assertions. No changes to application code are required to adopt it; the callbacks simply wrap existing functions.
Compatibility. Verify the package's PHP version constraint against the lowest PHP version you must support in CI (Laravel-version-aligned matrix). Because it is dev-only, you are not bound by production PHP constraints, but your CI matrix still has to run the package on whatever PHP the job uses. Framework compatibility is a non-issue given the absence of framework coupling.
Sequencing.
warmup() + deviations() to confirm the numbers align with real-world impact.round(), and disableProgressBar() for CI.max thresholds (e.g., 15–20%) to absorb noise, commit .snap files, and pin the runner.Maintenance. Low ongoing cost as a dev dependency. The main maintenance surface is the benchmark suite itself (callbacks, snapshots, thresholds), not the package. Snapshot files must be version-controlled and periodically re-baselined — treat this as a recurring, owned task rather than a one-time setup. Upgrades are infrequent and the 4.x API is small.
Support. Community-supported by a single maintainer, MIT-licensed, with modest adoption signals (121 stars, 0 reported dependents). Support expectation should be "GitHub issues best-effort," not commercial SLA. Mitigate by keeping usage narrow and relying on the stable public API (compare, iterations, warmup, toConsole, toData, toAssert) so replacement cost stays low.
Scaling. The tool is not a load or performance-profiling solution at scale — it measures in-process execution of small callbacks. Runtime cost scales with iterations × callbacks × deviations, so CI minutes are modest when iterations are kept in the tens-to-low-hundreds. It will not answer capacity-planning questions; pair it with APM/load-testing tooling for production-facing scaling concerns.
Failure modes.
0 bytes for small allocations, so memory assertions may not bite.AssertionError, which must be handled deliberately in CI configuration to avoid surprise red builds.Ramp-up. Very low for developers — the helper function and fluent API are learnable in well under an hour, and the README is concise with clear examples. The real ramp-up is methodological, not syntactic: engineers need a shared understanding of warm-up, iteration counts, deviation, and environmental controls before the results should be trusted in automated decisions. Budget a short internal guideline doc; without it, teams tend to over-trust noisy numbers or abandon the tool after the first flaky assertion.
How can I help you explore Laravel packages today?