Add testo/bench benchmarks and document performance trade-offs#8
Merged
Conversation
- Add testo/bench ^0.1.5 to require-dev, testo.php config, benchmarks/ dir - SpecificationBuilderBench: builder chain vs direct CompositeSpecification - OrCompositionBench: orWhere() vs direct OrSpecification::create() - Document performance trade-offs in README and llms.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
testo/bench ^0.1.5torequire-devwithtesto.phpconfig andbenchmarks/directoryCompositeSpecificationcompositionREADME.mdandllms.txtBenchmark results (PHP 8.5, Docker, no OPcache)
SpecificationBuilderBench — 7-step chain (5 conditions + limit + offset):
SpecificationBuilder(current)CompositeSpecificationdirectOverhead = 7
clone $thisoperations (one per builder step).OrCompositionBench — OR with 3 branches:
orWhere()callbackOrSpecification::create()directOverhead = temporary mutable builder + closure invocation per
orWhere()call.All RStDev < 2% — results are stable.
Why this matters
For typical web requests (1–5 specs, DB query ≫ builder cost) the overhead is negligible.
The documentation clarifies when to prefer the direct API (high-throughput batch loops).
Run benchmarks
composer bench # or make bench