| Crates.io | test_cpu_parallel |
| lib.rs | test_cpu_parallel |
| version | 1.3.2 |
| created_at | 2025-04-30 14:32:43.422731+00 |
| updated_at | 2025-12-10 15:42:14.207025+00 |
| description | Generate CPU- or memory-intensive workloads for benchmarking. |
| homepage | https://github.com/LucaCanali/Miscellaneous/tree/master/Performance_Testing/Test_CPU_parallel_Rust |
| repository | https://github.com/LucaCanali/Miscellaneous |
| max_upload_size | |
| id | 1654990 |
| size | 46,641 |
test_cpu_parallel is a small, zero‑dependency load‑testing kit. It can:
A two‑minute build, no external data files, works on Linux, macOS and Windows.
Link to the Project page
| what you want | command |
|---|---|
| CLI binary (optimised) | cargo install test_cpu_parallel |
| Library in an app / lib | cargo add test_cpu_parallel |
| Build from source | git clone … && cargo build --release |
Note Note The tool intentionally disables compiler optimizations using an unoptimized build for
cargo build --releaseandcargo install(by settingopt-level = 0). Whilecargo buildalso generates an unoptimized binary for debug, it is not equivalent to a --release build. For consistent performance comparisons, avoid mixing cargo build binaries with --release binaries.
# Burn four threads for a few seconds
$ test_cpu_parallel -w 4
# Sweep 1 → 16 threads, write CSV
$ test_cpu_parallel --num_workers 16 --full -o results.csv
# Stress memory with 8 workers and a 512 MiB buffer
$ test_cpu_parallel -w 8 --mode memory --memory_size 512
Run test_cpu_parallel --help for the complete flag list (excerpt below).
Usage: test_cpu_parallel [OPTIONS]
-w, --num_workers <N> parallel threads (default 2)
-m, --mode <cpu|memory> workload type (default cpu)
-f, --full sweep 1‥=N threads
-o, --output_file <PATH> write CSV (full mode)
--memory_size <MiB> buffer for memory test (default 1024)
Embed the engine in unit tests, benchmarks or monitoring agents:
use test_cpu_parallel::TestCPUParallel;
fn main() -> anyhow::Result<()> {
// 4 workers, one batch, memory workload, 64 MiB buffer
let bench = TestCPUParallel::new(4, 1, 1_000, "", 64);
let (thread_stats, batch_stats) = bench.test_one_load(None, "memory")?;
println!("Per‑thread stats: {thread_stats:?}");
println!("Per‑batch stats: {batch_stats:?}");
Ok(())
}
API docs are hosted on docs.rs/test_cpu_parallel.
# Clone and build a debug binary (recommended for comparable timings)
$ git clone https://github.com/LucaCanali/Miscellaneous.git
$ cd Miscellaneous/Performance_Testing/Test_CPU_parallel_Rust
$ cargo build --release
Full‑mode output is a single CSV line per thread count, ready to feed into
Python/pandas, gnuplot or Excel. See the Notebooks/ directory in the repo for ready‑made Jupyter notebooks that plot speed‑up and efficiency curves.
Enjoy hacking your CPUs 🔥