codeflash-agent/plugin/references/shared/micro-benchmark.md
Kevin Turcios 3b59d97647 squash
2026-04-13 14:12:17 -05:00

1.2 KiB

Micro-Benchmark — Shared Template

For any optimization, test in isolation first. Call the target function directly — not through the full application — to isolate its true impact.

Role

Micro-benchmarks are a fast pre-screen — validate that an optimization is worth committing before investing in a full E2E benchmark run. See e2e-benchmarks.md for how this fits into the two-phase measurement workflow and for fallback behavior when E2E benchmarks are not available.

A/B Pattern

Write a benchmark script with two variants — the current approach and the optimized approach — using the same realistic input. The script should accept a command-line argument to select the variant.

See your language's micro-benchmark.md for the template and tooling.

Micro-Benchmark-Only Keeps

Keep on micro alone if ALL hold:

  1. Micro-benchmark shows clear, repeatable improvement above the domain threshold
  2. Full tests still pass (always run for correctness)
  3. Change is simple, doesn't add complexity
  4. Function is confirmed on the hot path / exercised by the target test

See your language's micro-benchmark.md for domain-specific thresholds.

These saves compound: as dominant bottlenecks shrink, previously-buried savings surface.