Skip to main content

bench

Attribute Macro bench 

Source
#[bench]
Expand description

Mark a function as a benchmark.

§Supported signatures

#[pbench::bench]
fn no_args() { /* ... */ }

#[pbench::bench]
fn with_bencher(b: &Bencher) { /* ... */ }

#[pbench::bench(args = [1, 2, 4, 8])]
fn with_args(b: &Bencher, arg: &str) { /* ... */ }

§Options

  • sample_count = <expr> — number of samples
  • sample_size = <expr> — iterations per sample
  • min_time = <seconds> — minimum benchmark duration (f64 seconds)
  • max_time = <seconds> — maximum benchmark duration (f64 seconds)
  • skip_ext_time — skip external time in min/max accounting
  • args = [<exprs>] — runtime arguments (requires 2-param fn signature)
  • ignore — skip this benchmark unless --include-ignored is passed