Luigit
repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by admin

smith-bench/benches/calibration.rs

Raw
//! Callgrind calibration surface for Clap startup short help (`SMH-SPEC-SPEC0001`).
//!
//! The eight `basis_*` cases are a 2 × 2 × 2 factorial basis over command
//! children, root global arguments, and descriptor text bytes.
//! The fixture measures root `get_matches_from(["smith", "--help"])`, matching
//! production's short-help exit path without a forced recursive build or surface scan.
//! `heldout_*_path` cases are new predeclared validation only: coefficients never fit them.
//! This bench records evidence only; `cargo x calibrate` never reads or writes pins.

#![expect(
    missing_docs,
    reason = "gungraun benchmark macros generate undocumented public modules and items"
)]

use gungraun::Callgrind;
use gungraun::prelude::*;

fn fixture(arguments: &[&str]) -> gungraun::Command {
    let binary = std::env::var("CALIBRATION_BIN")
        .expect("CALIBRATION_BIN names clap-calibration; run `cargo x calibrate`");
    gungraun::Command::new(binary).args(arguments).build()
}

#[binary_benchmark]
#[bench::basis_low_low_low(&["--commands", "4", "--arguments", "2", "--text-bytes", "64"])]
#[bench::basis_low_low_high(&["--commands", "4", "--arguments", "2", "--text-bytes", "1024"])]
#[bench::basis_low_high_low(&["--commands", "4", "--arguments", "16", "--text-bytes", "64"])]
#[bench::basis_low_high_high(&["--commands", "4", "--arguments", "16", "--text-bytes", "1024"])]
#[bench::basis_high_low_low(&["--commands", "12", "--arguments", "2", "--text-bytes", "64"])]
#[bench::basis_high_low_high(&["--commands", "12", "--arguments", "2", "--text-bytes", "1024"])]
#[bench::basis_high_high_low(&["--commands", "12", "--arguments", "16", "--text-bytes", "64"])]
#[bench::basis_high_high_high(&["--commands", "12", "--arguments", "16", "--text-bytes", "1024"])]
#[bench::heldout_narrow_path(&["--commands", "6", "--arguments", "5", "--text-bytes", "320"])]
#[bench::heldout_balanced_path(&["--commands", "10", "--arguments", "10", "--text-bytes", "640"])]
#[bench::heldout_large_path(&["--commands", "20", "--arguments", "24", "--text-bytes", "1536"])]
fn clap_help(arguments: &[&str]) -> gungraun::Command {
    fixture(arguments)
}

binary_benchmark_group!(name = surface, benchmarks = clap_help);

main!(
    config = BinaryBenchmarkConfig::default().tool(Callgrind::with_args(["--cache-sim=no"])),
    binary_benchmark_groups = surface
);