meilisearch/milli/benches/search.rs

37 lines
1.0 KiB
Rust
Raw Normal View History

use std::time::Duration;
2020-06-19 00:37:57 +08:00
use heed::EnvOpenOptions;
2020-07-12 06:16:41 +08:00
use milli::Index;
use criterion::{criterion_group, criterion_main, BenchmarkId};
2020-06-19 00:37:57 +08:00
fn bench_search(c: &mut criterion::Criterion) {
2020-06-19 00:37:57 +08:00
let database = "books-4cpu.mmdb";
let queries = [
"minogue kylie",
"minogue kylie live",
];
2020-06-19 00:37:57 +08:00
2020-11-01 04:53:21 +08:00
let mut options = EnvOpenOptions::new();
options.map_size(100 * 1024 * 1024 * 1024); // 100 GB
options.max_readers(10);
let index = Index::new(options, database).unwrap();
2020-06-19 00:37:57 +08:00
let mut group = c.benchmark_group("search");
group.sample_size(10);
group.measurement_time(Duration::from_secs(12));
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();
});
});
}
group.finish();
2020-06-19 00:37:57 +08:00
}
criterion_group!(benches, bench_search);
criterion_main!(benches);