Skip to content

Add testo/bench benchmarks and document performance trade-offs#8

Merged
rasuvaeff merged 1 commit into
masterfrom
feat/testo-benchmarks
Jun 21, 2026
Merged

Add testo/bench benchmarks and document performance trade-offs#8
rasuvaeff merged 1 commit into
masterfrom
feat/testo-benchmarks

Conversation

@rasuvaeff

Copy link
Copy Markdown
Owner

Summary

  • Add testo/bench ^0.1.5 to require-dev with testo.php config and benchmarks/ directory
  • Two benchmark classes comparing builder API vs direct CompositeSpecification composition
  • Document performance characteristics in README.md and llms.txt

Benchmark results (PHP 8.5, Docker, no OPcache)

SpecificationBuilderBench — 7-step chain (5 conditions + limit + offset):

Mean* RStDev*
SpecificationBuilder (current) 3.25µs ±0.58%
CompositeSpecification direct 2.41µs (−26%) ±1.57%

Overhead = 7 clone $this operations (one per builder step).

OrCompositionBench — OR with 3 branches:

Mean* RStDev*
orWhere() callback 2.78µs ±0.45%
OrSpecification::create() direct 1.43µs (−48%) ±0.80%

Overhead = 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

- 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
@rasuvaeff rasuvaeff merged commit 8bf7571 into master Jun 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant