Macro criterion::criterion_main[][src]

macro_rules! criterion_main {
    ( $( $group:path ),+ $(,)* ) => { ... };

Macro which expands to a benchmark harness.

Currently, using requires disabling the benchmark harness generated automatically by rustc. This can be done like so:

name = "my_bench"
harness = false

In this case, my_bench must be a rust file inside the ‘benches’ directory, like so:


Since we’ve disabled the default benchmark harness, we need to add our own:

extern crate criterion;
use criterion::Criterion;
fn bench_method1(c: &mut Criterion) {

fn bench_method2(c: &mut Criterion) {

criterion_group!(benches, bench_method1, bench_method2);

The criterion_main macro expands to a main function which runs all of the benchmarks in the given groups.