Skip to main content

StressResult

Struct StressResult 

Source
pub struct StressResult {
    pub name: String,
    pub iterations: usize,
    pub threads: usize,
    pub total_elapsed: Duration,
    pub thread_times: Vec<Duration>,
    pub latency: Option<LatencyStats>,
}
Expand description

Result of a stress run.

§Example

use dev_stress::{StressRun, Workload};

#[derive(Clone)]
struct Noop;
impl Workload for Noop {
    fn run_once(&self) { std::hint::black_box(1 + 1); }
}

let r = StressRun::new("noop").iterations(100).threads(2).execute(&Noop);
assert!(r.ops_per_sec() > 0.0);

Fields§

§name: String

Stable name of the run.

§iterations: usize

Iterations actually executed.

§threads: usize

Threads used.

§total_elapsed: Duration

Wall-clock time from run start to all threads finishing.

§thread_times: Vec<Duration>

Per-thread elapsed times. Variance here indicates contention.

§latency: Option<LatencyStats>

Per-operation latency percentiles, when StressRun::track_latency was enabled. None otherwise.

Implementations§

Source§

impl StressResult

Source

pub fn ops_per_sec(&self) -> f64

Effective throughput in operations per second.

Source

pub fn thread_time_cv(&self) -> f64

Coefficient of variation across thread times. Higher numbers indicate worse contention or load imbalance.

Source

pub fn into_check_result(self, baseline_ops_per_sec: Option<f64>) -> CheckResult

Convert this result into a CheckResult using the legacy behavior (90%-baseline ops/sec floor, no latency thresholds).

baseline_ops_per_sec is the previously-recorded throughput. None -> Pass with detail. Below 90% baseline -> Fail+Warning. Otherwise Pass.

§Example
use dev_stress::{StressRun, Workload};

#[derive(Clone)]
struct Noop;
impl Workload for Noop { fn run_once(&self) {} }

let r = StressRun::new("noop").iterations(100).threads(1).execute(&Noop);
let _check = r.into_check_result(None);
Source

pub fn compare_with_options(&self, opts: &CompareOptions) -> CheckResult

Compare this result against a baseline using full options.

Always returns a CheckResult tagged stress, with numeric Evidence for iterations, threads, ops_per_sec, thread_time_cv, total_elapsed_ms, plus latency percentiles (when tracked) and any baseline values provided.

§Example
use dev_stress::{CompareOptions, StressRun, Workload};
use std::time::Duration;

#[derive(Clone)]
struct Noop;
impl Workload for Noop { fn run_once(&self) {} }

let r = StressRun::new("noop").iterations(100).threads(1).execute(&Noop);
let opts = CompareOptions {
    baseline_ops_per_sec: Some(1_000_000.0),
    ops_drop_pct_threshold: 10.0,
    baseline_p99: None,
    p99_regression_pct_threshold: 20.0,
};
let _ = r.compare_with_options(&opts);
Source

pub fn into_report( self, subject_version: impl Into<String>, opts: &CompareOptions, ) -> Report

Build a one-check Report containing the comparison result.

Sets subject = self.name, producer = "dev-stress".

Trait Implementations§

Source§

impl Clone for StressResult

Source§

fn clone(&self) -> StressResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StressResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.