Expand description
§aatxe-bench
Authoring API + JSON emitter for aatxe-compatible Rust microbenchmarks.
§Quick start
ⓘ
use aatxe_bench::{bench, Suite};
fn main() {
let mut suite = Suite::new("my-service");
bench(&mut suite, "parse_phone", || {
let _ = parse_phone("+34 612 345 678");
});
suite.emit_stdout();
}Running the binary that calls suite.emit_stdout() prints a fully-formed
aatxe_core::types::RunReport JSON, which aatxe run --lang rust
ingests directly.
§Why a builder, not #[bench]?
The stable Rust toolchain does not ship #[bench]. Criterion is the
standard alternative but introduces a heavy dependency tree and a
HTML-report-centric flow. Aatxe-bench instead exposes a small builder
that integrates cleanly with cargo run --release — predictable,
statically-typed, and trivial to embed in CI.
The sampling loop mirrors the JS authoring API:
- warmup iterations excluded from the measurement;
- adaptive sampling that stops once the CV drops below
Options::target_cvor the time budget expires orOptions::max_iterationsis hit; - automatic batch sizing for sub-µs operations.
Structs§
- Options
- Per-bench tuning knobs. Defaults match the JS / aatxe-core defaults so a service can swap between languages without changing its CI gate.
- Suite
- Collection of benches that will be emitted as a single
RunReport.
Enums§
Functions§
- bench
- Convenience wrapper that uses default
Optionsand a synthetic file tag. - black_
box - Re-exported so bench authors can
use aatxe_bench::black_box;without an extrastd::hintimport. Wrapping a value withblack_boxprevents LLVM from constant-folding or DCE-ing the benched expression. An identity function that hints to the compiler to be maximally pessimistic about whatblack_boxcould do. - keep
- Defeat dead-code elimination on a benched expression. Returns
vunchanged so it can be chained inline: