Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/change Example #407

Closed
Pardoxa opened this issue Apr 30, 2020 · 4 comments
Closed

Add/change Example #407

Pardoxa opened this issue Apr 30, 2020 · 4 comments
Milestone

Comments

@Pardoxa
Copy link

Pardoxa commented Apr 30, 2020

It would be nice to have an example for how to increase the sample size etc.

It took me longer than I am willing to admit to finally figure out, where I should use the corresponding members (e.g., sample_size) and it would have helped me a lot, if I found an example like:

use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn fibonacci(n: u64) -> u64 {
    match n {
        0 => 1,
        1 => 1,
        n => fibonacci(n-1) + fibonacci(n-2),
    }
}

fn criterion_benchmark(c: &mut Criterion) {
    c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
}

criterion_group!(benches, criterion_benchmark);

criterion_group!{
    name = benches;
    config = Criterion::default().sample_size(200);  // changing e.g, sampling size
    targets = criterion_benchmark
}

criterion_main!(benches);
@minghu6
Copy link

minghu6 commented May 17, 2020

criterion_group!(benches, criterion_benchmark);

just remove this line

@minghu6
Copy link

minghu6 commented May 17, 2020

@Pardoxa thank you very much ! I should have wasted many hours of my life without your post!

@0o-de-lally
Copy link

+1

@bheisler bheisler added this to the 0.3.3 milestone Jun 29, 2020
@bheisler
Copy link
Owner

Thanks for the suggestion. I've added a section to the Advanced Configuration page in the user guide with a couple of examples of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants