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: StringStable name of the run.
iterations: usizeIterations actually executed.
threads: usizeThreads used.
total_elapsed: DurationWall-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
impl StressResult
Sourcepub fn ops_per_sec(&self) -> f64
pub fn ops_per_sec(&self) -> f64
Effective throughput in operations per second.
Sourcepub fn thread_time_cv(&self) -> f64
pub fn thread_time_cv(&self) -> f64
Coefficient of variation across thread times. Higher numbers indicate worse contention or load imbalance.
Sourcepub fn into_check_result(self, baseline_ops_per_sec: Option<f64>) -> CheckResult
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);Sourcepub fn compare_with_options(&self, opts: &CompareOptions) -> CheckResult
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);Sourcepub fn into_report(
self,
subject_version: impl Into<String>,
opts: &CompareOptions,
) -> Report
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
impl Clone for StressResult
Source§fn clone(&self) -> StressResult
fn clone(&self) -> StressResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more