Add a second benchmark

This commit is contained in:
Michael Partheil 2023-10-03 17:13:36 +02:00 committed by Dirkjan Ochtman
parent ff32a353f8
commit 5e232a3d6f
1 changed files with 12 additions and 1 deletions

View File

@ -5,7 +5,7 @@ use bencher::{benchmark_group, benchmark_main, Bencher};
use instant_segment::test_data::{crate_data_dir, segmenter}; use instant_segment::test_data::{crate_data_dir, segmenter};
use instant_segment::Search; use instant_segment::Search;
benchmark_group!(benches, short); benchmark_group!(benches, short, long);
benchmark_main!(benches); benchmark_main!(benches);
fn short(bench: &mut Bencher) { fn short(bench: &mut Bencher) {
@ -15,3 +15,14 @@ fn short(bench: &mut Bencher) {
let _ = segmenter.segment("thisisatest", &mut search); let _ = segmenter.segment("thisisatest", &mut search);
}); });
} }
fn long(bench: &mut Bencher) {
let segmenter = segmenter(crate_data_dir());
let mut search = Search::default();
bench.iter(|| {
let _ = segmenter.segment(
"itwasabrightcolddayinaprilandtheclockswerestrikingthirteen",
&mut search,
);
});
}