Skip to content

Establish a benchmark baseline with regression comparison - #59

Merged
mmucklo merged 3 commits into
masterfrom
chore/benchmark-baseline
Jul 13, 2026
Merged

Establish a benchmark baseline with regression comparison#59
mmucklo merged 3 commits into
masterfrom
chore/benchmark-baseline

Conversation

@mmucklo

@mmucklo mmucklo commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Adds benchmarking tooling so the PhpBench suite protects against regressions, plus a non-blocking CI job that runs it on every PR.

What

  • composer bench:baseline — record/overwrite a local baseline tag.
  • composer bench:compare — run the suite and diff each subject against the baseline.
  • Stabilized runner (phpbench.json): 5 iterations, 2 warmup, 5% retry threshold → rstdev dropped from ~25% to <4%. Removed the @Iterations/@Warmup annotations in ParseBench.php that were silently overriding the config.
  • .phpbench/ git-ignored — wall-clock times are machine/PHP-specific and not portable.
  • benchmarks/BASELINE.md documents the workflow, reference figures, and host context.

CI integration

New non-blocking benchmarks job (pull_request only):

  1. Records a baseline from the PR base's src/, using this PR's benchmark harness/config.
  2. Restores head src/ and compares — same runner, same job, so machine-dependent times are apples-to-apples.
  3. Generous assertion (flags only >50%-slower-per-subject) + continue-on-error — surfaces the comparison table and catches real cliffs without blocking on shared-runner noise.

Not included (follow-up)

  • The actual hot-path optimization (pure-ASCII byte iteration vs mb_substr in the main loop) — the baseline now makes that measurable (≈134 μs/addr at batch scale to beat).

No library code changed — benchmarks, CI, config, and docs only.

Adds tooling to record a tagged PhpBench baseline and diff runs against it:
- composer bench:baseline  — record/overwrite the local `baseline` tag
- composer bench:compare   — run and diff each subject vs the baseline

Stabilizes the runner via phpbench.json (5 iterations, 2 warmup, 5% retry
threshold), dropping rstdev from ~25% to <4%. Iteration/warmup counts were
being overridden by @Iterations/@WarmUp annotations in ParseBench.php; removed
them so phpbench.json is the single source of truth.

Local storage (.phpbench/) is git-ignored — wall-clock times are machine- and
PHP-specific and not portable. benchmarks/BASELINE.md documents the workflow,
reference figures, and host context. ROADMAP updated; CI-side baselining left
as a follow-up.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.76%. Comparing base (1073d4c) to head (089d4c3).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #59      +/-   ##
============================================
+ Coverage     92.45%   92.76%   +0.30%     
  Complexity      380      380              
============================================
  Files             6        6              
  Lines           981      981              
============================================
+ Hits            907      910       +3     
+ Misses           74       71       -3     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

mmucklo added 2 commits July 12, 2026 22:40
Records a baseline from the PR base's src/ using this PR's benchmark harness,
then compares the head against it on the same runner — the only apples-to-apples
comparison for machine-dependent wall-clock times. Runs on pull_request only.

Non-blocking (continue-on-error) with a generous assertion: it flags only
catastrophic regressions (>50% slower per subject) to tolerate shared-runner
noise, and never blocks a merge. Surfaces the per-subject comparison table in
the job log.
@mmucklo
mmucklo merged commit f109878 into master Jul 13, 2026
14 checks passed
@mmucklo
mmucklo deleted the chore/benchmark-baseline branch July 13, 2026 05:49
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