Crate criterion

source ·
Expand description

A statistics-driven micro-benchmarking library written in Rust.

This crate is a microbenchmarking library which aims to provide strong statistical confidence in detecting and estimating the size of performance improvements and regressions, whle also being easy to use.

See the user guide for examples as well as details on the measurement and analysis process, and the output.


  • Benchmark Rust code as well as external programs
  • Collects detailed statistics, providing strong confidence that changes to performance are real, not measurement noise
  • Produces detailed charts, providing thorough understanding of your code’s performance behavior.


  • Macro used to define a benchmark group for the benchmark harness; see the criterion_main! macro for more details.
  • Macro which expands to a benchmark harness.


  • Timer struct to iterate a benchmarked function and measure the runtime.
  • Structure representing a benchmark (or group of benchmarks) which takes no parameters.
  • The benchmark manager
  • Representing a function to benchmark together with a name of that function. Used together with bench_functions to represent one out of multiple functions under benchmark.
  • Structure representing a benchmark (or group of benchmarks) which take one parameter.
  • Contains the configuration options for the plots generated by a particular benchmark or benchmark group.


  • Axis scaling type
  • Baseline describes how the baseline_directory is handled.
  • Argument to Bencher::iter_batched and Bencher::iter_batched_ref which controls the batch size.
  • Enum representing different ways of measuring the throughput of benchmarked code. If the throughput setting is configured for a benchmark then the estimated throughput will be reported as well as the time per iteration.


  • Common trait for Benchmark and ParameterizedBenchmark. Not intended to be used outside of


  • A function that is opaque to the optimizer, used to prevent the compiler from optimizing away computations in a benchmark.