Skip to content

chore: add self-benchmark suite under benchmarks/#20

Merged
chad-loder merged 4 commits into
mainfrom
chore/self-benchmarks
May 13, 2026
Merged

chore: add self-benchmark suite under benchmarks/#20
chad-loder merged 4 commits into
mainfrom
chore/self-benchmarks

Conversation

@chad-loder
Copy link
Copy Markdown
Owner

Summary

  • Adds a yarlpattern-only micro-benchmark suite under benchmarks/ covering the four hot paths: constructor cost, URLPattern.test(), URLPattern.exec(), and the yarl.URL input fast path.
  • 23 benchmarks across 4 files. No production-code changes, no behavior changes.

Why a separate suite (not in tests/)

The benchmark suite lives outside tests/ so the default pytest invocation does not pick it up (testpaths = ["tests"]). It is contributor / maintainer tooling — not something end users need to run.

Layout

benchmarks/
├── conftest.py                 shared fixtures + 4 representative pattern shapes
├── bench_construction.py       7 construction benchmarks
├── bench_test.py               6 test() benchmarks
├── bench_exec.py               6 exec() benchmarks
└── bench_yarl_fast_path.py     4 string-vs-yarl.URL pairs

Pattern shapes cover the spectrum: literal-only, named-group, regex-constrained, wildcard-tail, and the MDN kitchen-sink multi-component dict.

How to run

just bench           # run, print summary
just bench-save      # run, save baseline keyed on HEAD SHA

The harness is gated behind a PEP 735 [dependency-groups] entry (bench), pinning pytest-benchmark>=5.1.0. Not exposed as a published extra.

Test plan

  • just bench — all 23 benchmarks pass (locally verified)
  • uv run pytest -q — 580 passed, 19 skipped (no regression — default pytest does not touch benchmarks/)
  • just lint — all tools green (ruff, mypy, pyright, ty, semgrep, etc.)
  • Signed commit (ED25519)

Scope notes

Deliberately self-comparative only. Cross-library URLPattern benchmarks have their own methodological pitfalls (different parser, different regex engine, different I/O) and are out of scope for this PR.

Part of the v0.2.0 roadmap.

chad-loder and others added 2 commits May 12, 2026 19:58
Add a yarlpattern-only micro-benchmark suite covering the four hot paths
real callers exercise: constructor cost, ``URLPattern.test()`` throughput,
``URLPattern.exec()`` throughput, and the ``yarl.URL`` input fast path.

Layout:
  benchmarks/conftest.py          shared fixtures + a representative
                                  cross-section of pattern shapes
                                  (literal, named-group, regex-constrained,
                                  wildcard-tail, multi-component dict)
  benchmarks/bench_construction.py  4 + 3 = 7 construction benchmarks
  benchmarks/bench_test.py          6 test() benchmarks
  benchmarks/bench_exec.py          6 exec() benchmarks
  benchmarks/bench_yarl_fast_path.py
                                  4 string-vs-yarl.URL pairs

23 benchmarks in total. The suite is *not* picked up by the default
``pytest`` invocation (``testpaths = ["tests"]``); invoke explicitly:

    just bench          # run, print summary
    just bench-save     # run, save baseline keyed on HEAD SHA

The harness is pinned via the ``bench`` dependency-group (PEP 735), not a
published extra — pytest-benchmark is contributor / maintainer tooling.

The suite is deliberately self-comparative only: cross-library URLPattern
comparisons are a different exercise with their own methodological
pitfalls and are out of scope here.

Part of v0.2.0 roadmap.
@chad-loder chad-loder enabled auto-merge (squash) May 13, 2026 03:41
@chad-loder chad-loder merged commit 6109d3f into main May 13, 2026
19 checks passed
@chad-loder chad-loder deleted the chore/self-benchmarks branch May 13, 2026 03:47
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