When trying to follow code examples from Getting Started a user could be enticed by the copy&paste button in Step 2 - Add Benchmark to simply paste the code to his local file, but that sneaky button adds fn main() {, which blocks he invokation of the benchmark macro main function, so the benches would never run
#![allow(unused)]
fn main() {
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use mycrate::fibonacci;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
}
You should either
- remove the copy&paste button so that users would copy&paste manually without having that blocking main added
- configure docs to generate a button that doesn't copy the hidden text
- Or even better: have self-contained examples that work, then the user would simply download the files and don't have to waste time trying to figure out why the guide doesn't work
When trying to follow code examples from Getting Started a user could be enticed by the copy&paste button in Step 2 - Add Benchmark to simply paste the code to his local file, but that sneaky button adds
fn main() {, which blocks he invokation of the benchmark macro main function, so the benches would never runYou should either