2021-04-02 00:54:14 +08:00
|
|
|
mod utils;
|
2020-06-19 00:37:57 +08:00
|
|
|
|
2021-04-02 00:54:14 +08:00
|
|
|
use std::time::Duration;
|
2020-06-20 00:24:03 +08:00
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId};
|
2020-06-19 00:37:57 +08:00
|
|
|
|
2021-04-02 00:54:14 +08:00
|
|
|
fn bench_typo(c: &mut criterion::Criterion) {
|
|
|
|
let index = utils::base_setup(Some(vec!["typo".to_string()]));
|
|
|
|
|
2020-06-20 00:24:03 +08:00
|
|
|
let queries = [
|
2021-04-02 00:54:14 +08:00
|
|
|
"mongus ",
|
|
|
|
"thelonius monk ",
|
|
|
|
"Disnaylande ",
|
|
|
|
"the white striper ",
|
|
|
|
"indochie ",
|
|
|
|
"indochien ",
|
|
|
|
"klub des loopers ",
|
|
|
|
"fear of the duck ",
|
|
|
|
"michel depech ",
|
|
|
|
"stromal ",
|
|
|
|
"dire straights ",
|
|
|
|
"Arethla Franklin ",
|
2020-06-20 00:24:03 +08:00
|
|
|
];
|
2020-06-19 00:37:57 +08:00
|
|
|
|
2021-04-02 00:54:14 +08:00
|
|
|
let mut group = c.benchmark_group("typo");
|
2021-04-02 01:27:12 +08:00
|
|
|
group.measurement_time(Duration::from_secs(10));
|
2020-06-20 00:24:03 +08:00
|
|
|
|
|
|
|
for query in &queries {
|
|
|
|
group.bench_with_input(BenchmarkId::from_parameter(query), &query, |b, &query| {
|
|
|
|
b.iter(|| {
|
2020-11-01 04:53:21 +08:00
|
|
|
let rtxn = index.read_txn().unwrap();
|
2020-09-28 19:39:17 +08:00
|
|
|
let _documents_ids = index.search(&rtxn).query(*query).execute().unwrap();
|
2020-06-20 00:24:03 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
group.finish();
|
2020-06-19 00:37:57 +08:00
|
|
|
}
|
2020-06-20 00:24:03 +08:00
|
|
|
|
2021-04-02 00:54:14 +08:00
|
|
|
criterion_group!(benches, bench_typo);
|
2020-06-20 00:24:03 +08:00
|
|
|
criterion_main!(benches);
|