Skip to main content

BenchRunner

Struct BenchRunner 

Source
pub struct BenchRunner { /* private fields */ }
Expand description

Top-level orchestrator for benchmark execution.

Manages the full lifecycle of a benchmark run:

  1. Loading workloads (built-in or from file)
  2. Cost estimation and budget enforcement
  3. Warm-up phase (iterations discarded)
  4. Measurement phase (iterations recorded)
  5. Concurrent execution and sweep modes
  6. Metric aggregation and CV warnings
  7. Baseline save and regression detection

Implementations§

Source§

impl BenchRunner

Source

pub fn new(config: BenchConfig) -> Self

Creates a new BenchRunner with the given configuration.

Initializes BaselineStore at the configured baseline path and a default CostTracker with standard model pricing.

Source

pub async fn run(&self) -> Result<Vec<BenchmarkResult>>

Runs the full benchmark suite and returns results.

§Execution Flow
  1. Resolves workloads (specific workload via --workload or all built-in)
  2. Estimates cost and enforces budget (dry-run, max-cost-usd, confirm-cost)
  3. For each workload: a. Warm-up phase: run config.warmup iterations, discard results b. Measurement phase: run config.runs iterations, collect metrics c. If sweep mode: iterate through concurrency levels d. If concurrency > 1: spawn concurrent tasks
  4. Aggregates metrics and emits CV warnings
  5. Returns collected BenchmarkResult values
§Errors
Source

pub fn save_baseline(&self, results: &[BenchmarkResult]) -> Result<()>

Saves current results as the regression baseline.

Persists metrics via BaselineStore for later regression detection.

Source

pub fn check_regression( &self, results: &[BenchmarkResult], ) -> Result<Vec<RegressionReport>>

Checks results against saved baseline using configured tolerance.

For benchmark timing metrics, a regression means the current value is higher than the baseline (worse performance). The formula is:

regression detected when (current - baseline) / baseline > tolerance

Returns a list of RegressionReport entries for any metrics that exceed the tolerance threshold. An empty list means no regressions.

§Exit Code Contract

The CLI layer (Task 8.1) should exit with code 2 when this method returns a non-empty list, and exit with code 0 otherwise.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more