bench_matrix is a Rust crate for parameterized benchmarks. You describe the parameters you want to vary, such as data size, algorithm or concurrency level. It runs a benchmark for every combination through the Criterion harness.
Without it, covering a grid of configurations usually means writing one benchmark function per combination or a hand-rolled loop around Criterion groups. With bench_matrix you define each parameter axis once as a list of MatrixCellValue entries (unsigned numbers, strings and so on) and the crate generates the Cartesian product. Combinations are produced lazily, so a matrix with a very large number of variants does not need to be built in memory up front.
Each combination is turned into your own typed configuration struct by an extractor function you supply. A suite then drives a lifecycle around the measured code: global_setup, a setup that builds per-run state, the benchmark logic itself and a teardown. SyncBenchmarkSuite handles synchronous code and AsyncBenchmarkSuite handles async code on Tokio, with the same shape for both. You can attach a throughput calculation per configuration so Criterion reports elements or bytes per second.
Results come out in named Criterion groups built from the parameter names and values. A suite called DataProcessingSuite with Elements and Intensity axes reports entries such as DataProcessingSuite/Elements-100_Intensity-Low, so each result says which configuration produced it. Criterion's statistics and plots work as usual.
[]
= "0.2"
= "0.5"The criterion_integration feature is on by default. Tokio is needed only for async suites.
Licensed under MPL-2.0. Source at https://github.com/excsn/bench_matrix and API docs at https://docs.rs/bench_matrix.
