Add simple benchmark

This commit is contained in:
Dirkjan Ochtman 2020-05-28 19:56:13 +02:00
parent 38f9747c92
commit c11b30526d
2 changed files with 23 additions and 0 deletions

View File

@ -9,4 +9,9 @@ license = "Apache-2.0"
err-derive = "0.2.4"
[dev-dependencies]
bencher = "0.1.5"
once_cell = "1.4"
[[bench]]
name = "bench"
harness = false

18
benches/bench.rs Normal file
View File

@ -0,0 +1,18 @@
use std::path::PathBuf;
use bencher::{benchmark_group, benchmark_main, Bencher};
use word_segmenters::Segmenter;
benchmark_group!(benches, short);
benchmark_main!(benches);
fn short(bench: &mut Bencher) {
let segmenter = Segmenter::from_dir(&PathBuf::from(format!(
"{}/data",
env!("CARGO_MANIFEST_DIR")
)))
.unwrap();
bench.iter(|| segmenter.segment("thisisatest"));
}