cntryl-stress
A lightweight single-shot benchmark runner for system-level stress tests.
Unlike Criterion (which uses statistical sampling), this crate is designed for expensive operations where each iteration matters: disk I/O, network calls, database transactions, compaction, recovery, etc.
Features
cargo stresscommand — run benchmarks likecargo test#[stress_test]attribute — auto-discovery of benchmark functions- Single-shot measurements — no statistical sampling overhead
- Explicit timing control — setup and teardown are not included in measurements
- Glob filtering — run subsets with
--workload "pattern*" - Pluggable reporters — Console, JSON
- Baseline comparison — detect regressions against previous runs
- Throughput tracking — report bytes/sec or ops/sec
Quick Start
1. Add the dependency
[]
= "0.1"
2. Create a stress test file
Create benches/my_test.rs:
use ;
3. Run your benchmarks
# Run all stress tests
# Filter by glob pattern
# Multiple runs (reports median)
# Include ignored tests
# List available benchmarks
# Compare against baseline
Command Line Reference
cargo stress [OPTIONS]
Options:
--workload <PATTERN> Filter benchmarks by glob pattern
--runs <N> Number of measurement runs [default: 1]
--warmup <N> Warmup runs (discarded) [default: 0]
-v, --verbose Verbose output
-q, --quiet Minimal output
--include-ignored Run benchmarks marked with #[stress_test(ignore)]
--baseline <FILE> Compare against baseline JSON
--threshold <FLOAT> Regression threshold (e.g., 0.05 for 5%) [default: 0.05]
--list List benchmarks without running
-h, --help Print help
Attribute Options
// Basic benchmark
// Ignored by default (opt-in with --include-ignored)
// Custom name (instead of function name)
Manual Runner Style
For more control over execution, use BenchRunner directly:
use ;
let mut runner = new;
runner.run;
let results = runner.finish;
Configuration
Configure via environment variables or the builder API:
| Variable | Default | Description |
|---|---|---|
BENCH_RUNS |
1 |
Number of measurement runs (reports median) |
BENCH_WARMUP |
0 |
Warmup runs (discarded) |
BENCH_VERBOSE |
true |
Print results to stderr |
BENCH_OUTPUT_DIR |
target/stress |
Directory for JSON results |
BENCH_FILTER |
- | Filter benchmarks by name substring |
BENCH_GIT_SHA |
auto-detected | Git commit hash to include in results |
Builder API:
use ;
let config = new
.runs
.warmup
.verbose
.filter;
let mut runner = with_config;
Throughput Reporting
// Output: write_data ... 15.32ms (65.28 MB/s)
Baseline Comparison
Detect performance regressions in CI:
# Save baseline
# Compare against baseline (fails if >5% slower)
Project Structure
your-project/
├── src/ # Your library code
├── benches/ # Stress tests (just drop .rs files here)
│ └── my_stress.rs
└── Cargo.toml
That's it! No Cargo.toml changes needed. cargo stress auto-discovers files in benches/ and builds them.
Installation
Install the cargo stress command globally:
Or for development: