Initial commit.
This commit is contained in:
22
benches/bench.rs
Normal file
22
benches/bench.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
#[macro_use]
|
||||
extern crate criterion;
|
||||
|
||||
extern crate byte_ngram;
|
||||
|
||||
use criterion::{Criterion, Fun};
|
||||
|
||||
use byte_ngram::{ByteNgramReader, from_slice};
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let data = String::from("Blackmail is such an ugly word. I prefer extortion. The 'x' makes it sound cool.");
|
||||
|
||||
let fn_from_slice = Fun::new("from_slice", |b, i: &String| b.iter(|| for _ in from_slice(i.as_bytes()) {}));
|
||||
let fn_from_reader = Fun::new("ByteNgramReader", |b, i: &String| b.iter(|| for _ in ByteNgramReader::new(i.as_bytes()) {}));
|
||||
|
||||
let functions = vec![fn_from_slice, fn_from_reader];
|
||||
|
||||
c.bench_functions("Read", functions, &data);
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
Reference in New Issue
Block a user