mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
merge all the criterion only benchmarks in one file
This commit is contained in:
parent
a2bff68c1a
commit
3def42abd8
@ -61,13 +61,5 @@ rand = "0.8.3"
|
|||||||
default = []
|
default = []
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "typo"
|
name = "criterion"
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "words"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "proximity"
|
|
||||||
harness = false
|
harness = false
|
||||||
|
58
milli/benches/criterion.rs
Normal file
58
milli/benches/criterion.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
mod utils;
|
||||||
|
|
||||||
|
use criterion::{criterion_group, criterion_main};
|
||||||
|
|
||||||
|
fn bench_criterion(c: &mut criterion::Criterion) {
|
||||||
|
let confs = &[
|
||||||
|
utils::Conf {
|
||||||
|
group_name: "proximity",
|
||||||
|
queries: &[
|
||||||
|
"black saint sinner lady ",
|
||||||
|
"les dangeureuses 1960 ",
|
||||||
|
"The Disneyland Sing-Along Chorus ",
|
||||||
|
"Under Great Northern Lights ",
|
||||||
|
"7000 Danses Un Jour Dans Notre Vie",
|
||||||
|
],
|
||||||
|
criterion: Some(&["proximity"]),
|
||||||
|
optional_words: false,
|
||||||
|
},
|
||||||
|
utils::Conf {
|
||||||
|
group_name: "typo",
|
||||||
|
queries: &[
|
||||||
|
"mongus ",
|
||||||
|
"thelonius monk ",
|
||||||
|
"Disnaylande ",
|
||||||
|
"the white striper ",
|
||||||
|
"indochie ",
|
||||||
|
"indochien ",
|
||||||
|
"klub des loopers ",
|
||||||
|
"fear of the duck ",
|
||||||
|
"michel depech ",
|
||||||
|
"stromal ",
|
||||||
|
"dire straights ",
|
||||||
|
"Arethla Franklin ",
|
||||||
|
],
|
||||||
|
criterion: Some(&["typo"]),
|
||||||
|
optional_words: false,
|
||||||
|
},
|
||||||
|
utils::Conf {
|
||||||
|
group_name: "words",
|
||||||
|
queries: &[
|
||||||
|
"the black saint and the sinner lady and the good doggo ", // four words to pop
|
||||||
|
"les liaisons dangeureuses 1793 ", // one word to pop
|
||||||
|
"The Disneyland Children's Sing-Alone song ", // two words to pop
|
||||||
|
"seven nation mummy ", // one word to pop
|
||||||
|
"7000 Danses / Le Baiser / je me trompe de mots ", // four words to pop
|
||||||
|
"Bring Your Daughter To The Slaughter but now this is not part of the title ", // nine words to pop
|
||||||
|
"whathavenotnsuchforth and then a good amount of words tot pop in order to match the first one ", // 16
|
||||||
|
],
|
||||||
|
criterion: Some(&["words"]),
|
||||||
|
optional_words: true,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
utils::run_benches(c, confs);
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, bench_criterion);
|
||||||
|
criterion_main!(benches);
|
@ -1,33 +0,0 @@
|
|||||||
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);
|
|
@ -1,40 +0,0 @@
|
|||||||
mod utils;
|
|
||||||
|
|
||||||
use std::time::Duration;
|
|
||||||
use criterion::{criterion_group, criterion_main, BenchmarkId};
|
|
||||||
|
|
||||||
fn bench_typo(c: &mut criterion::Criterion) {
|
|
||||||
let index = utils::base_setup(Some(vec!["typo".to_string()]));
|
|
||||||
|
|
||||||
let queries = [
|
|
||||||
"mongus ",
|
|
||||||
"thelonius monk ",
|
|
||||||
"Disnaylande ",
|
|
||||||
"the white striper ",
|
|
||||||
"indochie ",
|
|
||||||
"indochien ",
|
|
||||||
"klub des loopers ",
|
|
||||||
"fear of the duck ",
|
|
||||||
"michel depech ",
|
|
||||||
"stromal ",
|
|
||||||
"dire straights ",
|
|
||||||
"Arethla Franklin ",
|
|
||||||
];
|
|
||||||
|
|
||||||
let mut group = c.benchmark_group("typo");
|
|
||||||
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_typo);
|
|
||||||
criterion_main!(benches);
|
|
@ -1,9 +1,17 @@
|
|||||||
use std::{fs::{File, create_dir_all}};
|
use std::{fs::{File, create_dir_all}, time::Duration};
|
||||||
|
|
||||||
use heed::EnvOpenOptions;
|
use heed::EnvOpenOptions;
|
||||||
|
use criterion::BenchmarkId;
|
||||||
use milli::{Index, update::{IndexDocumentsMethod, UpdateBuilder, UpdateFormat}};
|
use milli::{Index, update::{IndexDocumentsMethod, UpdateBuilder, UpdateFormat}};
|
||||||
|
|
||||||
pub fn base_setup(criteria: Option<Vec<String>>) -> Index {
|
pub struct Conf<'a> {
|
||||||
|
pub group_name: &'a str,
|
||||||
|
pub queries: &'a[&'a str],
|
||||||
|
pub criterion: Option<&'a [&'a str]>,
|
||||||
|
pub optional_words: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn base_setup(criterion: Option<Vec<String>>) -> Index {
|
||||||
let database = "songs.mmdb";
|
let database = "songs.mmdb";
|
||||||
create_dir_all(&database).unwrap();
|
create_dir_all(&database).unwrap();
|
||||||
|
|
||||||
@ -16,12 +24,12 @@ pub fn base_setup(criteria: Option<Vec<String>>) -> Index {
|
|||||||
let mut wtxn = index.write_txn().unwrap();
|
let mut wtxn = index.write_txn().unwrap();
|
||||||
let mut builder = update_builder.settings(&mut wtxn, &index);
|
let mut builder = update_builder.settings(&mut wtxn, &index);
|
||||||
|
|
||||||
if let Some(criteria) = criteria {
|
if let Some(criterion) = criterion {
|
||||||
builder.reset_faceted_fields();
|
builder.reset_faceted_fields();
|
||||||
builder.reset_criteria();
|
builder.reset_criteria();
|
||||||
builder.reset_stop_words();
|
builder.reset_stop_words();
|
||||||
|
|
||||||
builder.set_criteria(criteria);
|
builder.set_criteria(criterion);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.execute(|_, _| ()).unwrap();
|
builder.execute(|_, _| ()).unwrap();
|
||||||
@ -39,3 +47,23 @@ pub fn base_setup(criteria: Option<Vec<String>>) -> Index {
|
|||||||
|
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_benches(c: &mut criterion::Criterion, confs: &[Conf]) {
|
||||||
|
for conf in confs {
|
||||||
|
let criterion = conf.criterion.map(|s| s.iter().map(|s| s.to_string()).collect());
|
||||||
|
let index = base_setup(criterion);
|
||||||
|
|
||||||
|
let mut group = c.benchmark_group(conf.group_name);
|
||||||
|
group.measurement_time(Duration::from_secs(10));
|
||||||
|
|
||||||
|
for &query in conf.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(conf.optional_words).execute().unwrap();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
group.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
mod utils;
|
|
||||||
|
|
||||||
use std::time::Duration;
|
|
||||||
use criterion::{criterion_group, criterion_main, BenchmarkId};
|
|
||||||
|
|
||||||
fn bench_words(c: &mut criterion::Criterion) {
|
|
||||||
let index = utils::base_setup(Some(vec!["words".to_string()]));
|
|
||||||
|
|
||||||
let queries = [
|
|
||||||
"the black saint and the sinner lady and the good doggo ", // four words to pop
|
|
||||||
"les liaisons dangeureuses 1793 ", // one word to pop
|
|
||||||
"The Disneyland Children's Sing-Alone song ", // two words to pop
|
|
||||||
"seven nation mummy ", // one word to pop
|
|
||||||
"7000 Danses / Le Baiser / je me trompe de mots ", // four words to pop
|
|
||||||
"Bring Your Daughter To The Slaughter but now this is not part of the title ", // nine words to pop
|
|
||||||
"whathavenotnsuchforth and then a good amount of words tot pop in order to match the first one ", // 16
|
|
||||||
];
|
|
||||||
|
|
||||||
let mut group = c.benchmark_group("words");
|
|
||||||
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).execute().unwrap();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
group.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
criterion_group!(benches, bench_words);
|
|
||||||
criterion_main!(benches);
|
|
Loading…
Reference in New Issue
Block a user