Skip to content

bench(routing): add criterion bench for classify_complexity (target 0.1ms)#270

Merged
Destynova2 merged 1 commit intomainfrom
bench/classify-latency
Apr 25, 2026
Merged

bench(routing): add criterion bench for classify_complexity (target 0.1ms)#270
Destynova2 merged 1 commit intomainfrom
bench/classify-latency

Conversation

@Destynova2
Copy link
Copy Markdown
Contributor

Summary

Adds a Criterion bench validating the "stateless ~0.1ms" design goal for the heuristic complexity classifier. Results are well under target.

Local results (Apple Silicon, dev profile)

Bench Time vs 100µs target
classify_trivial ~145 ns 690x faster
classify_medium ~33 ns ~3000x faster
classify_complex ~410 ns ~240x faster

`classify_medium` is faster than `classify_trivial` because the medium request has fewer alphanumeric tokens that match the keyword regex set; the trivial "What is 2+2?" forces a full token scan.

Files changed

  • `benches/classify.rs` — three scenarios (trivial / medium / complex)
  • `Cargo.toml` — `[[bench]] name = "classify" harness = false`
  • `src/routing/classify/mod.rs` — re-export `classify_complexity` so benches and external callers don't need the awkward `classify::classify` path

Test plan

  • `cargo build --bench classify` clean
  • `cargo clippy --bench classify -- -D warnings` clean
  • `cargo bench --bench classify` runs and produces stable results
  • CI green (auto-merge enabled below)

Note

Bench is local-only — `cargo bench` is not in CI today, this PR stays consistent with that policy. The numbers are captured in the commit body for future reference.

….1ms)

Three scenarios measure the cost of the heuristic complexity classifier
to validate the "stateless ~0.1ms" design goal. Results well under target.

Local results (Apple Silicon):
  classify_trivial   ~145 ns   (≈ 690x under 100µs target)
  classify_medium    ~33 ns    (≈ 3000x under target)
  classify_complex   ~410 ns   (≈ 240x under target)

Bench is local-only (cargo bench is not in CI today; staying consistent).

Side change: re-export `classify_complexity` from `routing::classify` so
external callers (benches, MCP tools) don't need the awkward double
`classify::classify::classify_complexity` path.
@Destynova2 Destynova2 enabled auto-merge April 25, 2026 18:32
@Destynova2 Destynova2 merged commit 9da62f6 into main Apr 25, 2026
42 checks passed
@Destynova2 Destynova2 deleted the bench/classify-latency branch April 25, 2026 18:42
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