2020-06-19 18:24:03 +02:00
|
|
|
use std::time::Duration;
|
2020-06-18 18:37:57 +02:00
|
|
|
|
|
|
|
use heed::EnvOpenOptions;
|
2020-07-12 00:16:41 +02:00
|
|
|
use milli::Index;
|
2020-06-19 18:24:03 +02:00
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId};
|
2020-06-18 18:37:57 +02:00
|
|
|
|
2020-06-19 18:24:03 +02:00
|
|
|
fn bench_search(c: &mut criterion::Criterion) {
|
2020-06-18 18:37:57 +02:00
|
|
|
let database = "books-4cpu.mmdb";
|
2020-06-19 18:24:03 +02:00
|
|
|
let queries = [
|
|
|
|
"minogue kylie",
|
|
|
|
"minogue kylie live",
|
|
|
|
];
|
2020-06-18 18:37:57 +02:00
|
|
|
|
|
|
|
std::fs::create_dir_all(database).unwrap();
|
|
|
|
let env = EnvOpenOptions::new()
|
|
|
|
.map_size(100 * 1024 * 1024 * 1024) // 100 GB
|
|
|
|
.max_readers(10)
|
|
|
|
.max_dbs(5)
|
|
|
|
.open(database).unwrap();
|
|
|
|
|
|
|
|
let index = Index::new(&env).unwrap();
|
|
|
|
|
2020-06-19 18:24:03 +02: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(|| {
|
|
|
|
let rtxn = env.read_txn().unwrap();
|
2020-09-28 13:39:17 +02:00
|
|
|
let _documents_ids = index.search(&rtxn).query(*query).execute().unwrap();
|
2020-06-19 18:24:03 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
group.finish();
|
2020-06-18 18:37:57 +02:00
|
|
|
}
|
2020-06-19 18:24:03 +02:00
|
|
|
|
|
|
|
criterion_group!(benches, bench_search);
|
|
|
|
criterion_main!(benches);
|