Add simple benchmark
This commit is contained in:
parent
38f9747c92
commit
c11b30526d
|
@ -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
|
||||
|
|
|
@ -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"));
|
||||
}
|
Loading…
Reference in New Issue