From aee49bb3cd20a88c0d62c735268086d0033e1ed5 Mon Sep 17 00:00:00 2001 From: tamo Date: Wed, 7 Apr 2021 11:04:53 +0200 Subject: [PATCH] add the proximity criterion --- milli/Cargo.toml | 4 ++++ milli/benches/proximity.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 milli/benches/proximity.rs diff --git a/milli/Cargo.toml b/milli/Cargo.toml index 5184d028b..156518e19 100644 --- a/milli/Cargo.toml +++ b/milli/Cargo.toml @@ -67,3 +67,7 @@ harness = false [[bench]] name = "words" harness = false + +[[bench]] +name = "proximity" +harness = false diff --git a/milli/benches/proximity.rs b/milli/benches/proximity.rs new file mode 100644 index 000000000..5b687855f --- /dev/null +++ b/milli/benches/proximity.rs @@ -0,0 +1,33 @@ +mod utils; + +use std::time::Duration; +use criterion::{criterion_group, criterion_main, BenchmarkId}; + +fn bench_proximity(c: &mut criterion::Criterion) { + let index = utils::base_setup(Some(vec!["words".to_string()])); + + let queries = [ + "black saint sinner lady ", + "les dangeureuses 1960 ", + "The Disneyland Sing-Alone song ", + "Under Great Northern Lights ", + "7000 Danses Un Jour Dans Notre Vie", + ]; + + let mut group = c.benchmark_group("proximity"); + group.measurement_time(Duration::from_secs(10)); + + for query in &queries { + group.bench_with_input(BenchmarkId::from_parameter(query), &query, |b, &query| { + b.iter(|| { + let rtxn = index.read_txn().unwrap(); + let _documents_ids = index.search(&rtxn).query(*query).optional_words(false).execute().unwrap(); + }); + }); + } + + group.finish(); +} + +criterion_group!(benches, bench_proximity); +criterion_main!(benches);