pub struct StressRun { /* private fields */ }Expand description
Configuration for a stress run.
§Example
use dev_stress::StressRun;
let run = StressRun::new("hot_path").iterations(1_000).threads(4);
assert_eq!(run.iterations_planned(), 1_000);
assert_eq!(run.threads_planned(), 4);Implementations§
Source§impl StressRun
impl StressRun
Sourcepub fn iterations(self, n: usize) -> Self
pub fn iterations(self, n: usize) -> Self
Total iterations across all threads.
Sourcepub fn track_latency(self, rate: usize) -> Self
pub fn track_latency(self, rate: usize) -> Self
Track per-operation latency, sampling 1 of every rate iterations.
rate = 1 records every iteration; rate = 100 records 1% of
iterations. Lower rates lower memory and overhead at the cost
of percentile precision.
§Example
use dev_stress::StressRun;
let run = StressRun::new("hot").iterations(10_000).threads(2)
.track_latency(10); // 10% sample rate
assert_eq!(run.iterations_planned(), 10_000);Sourcepub fn target_ops_per_sec(self, total_rate: f64) -> Self
pub fn target_ops_per_sec(self, total_rate: f64) -> Self
Cap the workload at approximately total_rate ops per second
(across all threads).
Implemented as a per-thread sleep based on observed elapsed time vs. ideal scheduling. Sleep precision varies by OS; for very high target rates (e.g. > 10k ops/sec/thread) the actual rate may be lower than the target due to sleep granularity.
§Example
use dev_stress::StressRun;
// Cap to ~1000 ops/sec total across 4 threads = 250 per thread.
let run = StressRun::new("rate-limited")
.iterations(500)
.threads(4)
.target_ops_per_sec(1000.0);
assert_eq!(run.threads_planned(), 4);Sourcepub fn iterations_planned(&self) -> usize
pub fn iterations_planned(&self) -> usize
The configured iteration count.
Sourcepub fn threads_planned(&self) -> usize
pub fn threads_planned(&self) -> usize
The configured thread count.
Sourcepub fn target_ops_per_sec_per_thread(&self) -> Option<f64>
pub fn target_ops_per_sec_per_thread(&self) -> Option<f64>
The configured per-thread target rate, if any.
Auto Trait Implementations§
impl Freeze for StressRun
impl RefUnwindSafe for StressRun
impl Send for StressRun
impl Sync for StressRun
impl Unpin for StressRun
impl UnsafeUnpin for StressRun
impl UnwindSafe for StressRun
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more