Created
April 24, 2018 13:09
-
-
Save robinst/a4a6f6223788cc15083d03a4b0c0a7c0 to your computer and use it in GitHub Desktop.
criterion-with-string-inputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate criterion; | |
use criterion::{Bencher, Criterion}; | |
fn example(b: &mut Bencher, s: &str) { | |
b.iter(|| s.len()); | |
} | |
fn example_benchmark(c: &mut Criterion) { | |
c.bench_function_over_inputs( | |
"fun", | |
|b, s| example(b, s), | |
vec![ | |
"foo", | |
"bar/baz" | |
] | |
); | |
} | |
criterion_group!(benches, example_benchmark); | |
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "criterion-test" | |
version = "0.1.0" | |
authors = ["Robin Stocker"] | |
[dev-dependencies] | |
criterion = "*" | |
[[bench]] | |
name = "example" | |
harness = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment