Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit f239c95

Browse files
committed
Only allow change of criteria before each new search group bench
1 parent 8408db7 commit f239c95

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

benchmarks/benches/search_geo.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ fn bench_geo(c: &mut criterion::Criterion) {
3434
dataset: datasets_paths::SMOL_ALL_COUNTRIES,
3535
dataset_format: "jsonl",
3636
primary_key: Some("geonameid"),
37+
configure: base_conf,
3738
..IndexConf::BASE
3839
};
39-
let base_index_settings_conf =
40-
IndexSettingsConf { configure: base_conf, ..IndexSettingsConf::BASE };
4140

4241
let confs = vec![(
43-
base_index_settings_conf,
42+
IndexSettingsConf::BASE,
4443
vec![
4544
// A basic placeholder with no geo
4645
SearchBenchConf { group_name: "placeholder with no geo", ..SearchBenchConf::BASE },

benchmarks/benches/search_songs.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ fn bench_songs(c: &mut criterion::Criterion) {
5050
let base_index_conf = IndexConf {
5151
dataset: datasets_paths::SMOL_SONGS,
5252
primary_key: Some("id"),
53+
configure: base_conf,
5354
..IndexConf::BASE
5455
};
55-
let base_index_settings_conf =
56-
IndexSettingsConf { configure: base_conf, ..IndexSettingsConf::BASE };
5756

5857
let default_criterion: Vec<String> =
5958
milli::default_criteria().iter().map(|criteria| criteria.to_string()).collect();
@@ -69,7 +68,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
6968
(
7069
IndexSettingsConf {
7170
criterion: Some(&["proximity"]),
72-
..base_index_settings_conf
7371
},
7472
vec![
7573
SearchBenchConf {
@@ -116,7 +114,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
116114
(
117115
IndexSettingsConf {
118116
criterion: Some(&["typo"]),
119-
..base_index_settings_conf
120117
},
121118
vec![
122119
SearchBenchConf {
@@ -144,7 +141,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
144141
(
145142
IndexSettingsConf {
146143
criterion: Some(&["words"]),
147-
..base_index_settings_conf
148144
},
149145
vec![
150146
SearchBenchConf {
@@ -166,7 +162,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
166162
(
167163
IndexSettingsConf {
168164
criterion: Some(&["released-timestamp:asc"]),
169-
..base_index_settings_conf
170165
},
171166
vec![
172167
SearchBenchConf {
@@ -189,7 +184,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
189184
(
190185
IndexSettingsConf {
191186
criterion: Some(&["released-timestamp:desc"]),
192-
..base_index_settings_conf
193187
},
194188
vec![
195189
SearchBenchConf {
@@ -212,7 +206,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
212206
(
213207
IndexSettingsConf {
214208
criterion: Some(&asc_default[..]),
215-
..base_index_settings_conf
216209
},
217210
vec![
218211
SearchBenchConf {
@@ -235,7 +228,6 @@ fn bench_songs(c: &mut criterion::Criterion) {
235228
(
236229
IndexSettingsConf {
237230
criterion: Some(&desc_default[..]),
238-
..base_index_settings_conf
239231
},
240232
vec![
241233
SearchBenchConf {

benchmarks/benches/search_wiki.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ fn base_conf(builder: &mut Settings) {
1717
}
1818

1919
fn bench_wiki(c: &mut criterion::Criterion) {
20-
let index_conf: IndexConf =
21-
IndexConf { dataset: datasets_paths::SMOL_WIKI_ARTICLES, ..IndexConf::BASE };
22-
let base_index_settings_conf =
23-
IndexSettingsConf { configure: base_conf, ..IndexSettingsConf::BASE };
20+
let index_conf: IndexConf = IndexConf {
21+
dataset: datasets_paths::SMOL_WIKI_ARTICLES,
22+
configure: base_conf,
23+
..IndexConf::BASE
24+
};
2425

2526
#[rustfmt::skip]
2627
let benches = vec![
2728
// First all the benches done on the index with only the proximity criterion
2829
(
2930
IndexSettingsConf {
3031
criterion: Some(&["proximity"]),
31-
..base_index_settings_conf
3232
},
3333
vec![
3434
SearchBenchConf {
@@ -72,7 +72,6 @@ fn bench_wiki(c: &mut criterion::Criterion) {
7272
(
7373
IndexSettingsConf {
7474
criterion: Some(&["typo"]),
75-
..base_index_settings_conf
7675
},
7776
vec![
7877
SearchBenchConf {
@@ -96,7 +95,6 @@ fn bench_wiki(c: &mut criterion::Criterion) {
9695
(
9796
IndexSettingsConf {
9897
criterion: Some(&["words"]),
99-
..base_index_settings_conf
10098
},
10199
vec![
102100
SearchBenchConf {
@@ -116,7 +114,7 @@ fn bench_wiki(c: &mut criterion::Criterion) {
116114
// /* the we bench some global / normal search with all the default criterion in the default
117115
// * order */
118116
(
119-
base_index_settings_conf,
117+
IndexSettingsConf::BASE,
120118
vec![
121119
SearchBenchConf {
122120
group_name: "basic placeholder",

benchmarks/benches/utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub struct IndexConf<'a> {
2424
pub dataset_format: &'a str,
2525
/// primary key, if there is None we'll auto-generate docids for every documents
2626
pub primary_key: Option<&'a str>,
27+
/// configure your database as you want
28+
pub configure: fn(&mut Settings),
2729
}
2830

2931
impl IndexConf<'_> {
@@ -32,6 +34,7 @@ impl IndexConf<'_> {
3234
dataset_format: "csv",
3335
dataset: "",
3436
primary_key: None,
37+
configure: |_| (),
3538
};
3639
}
3740

@@ -40,11 +43,9 @@ pub struct IndexSettingsConf<'a> {
4043
/// - if you specify something all the base configuration will be thrown out
4144
/// - if you don't specify anything (None) the default configuration will be kept
4245
pub criterion: Option<&'a [&'a str]>,
43-
/// configure your database as you want
44-
pub configure: fn(&mut Settings),
4546
}
4647
impl IndexSettingsConf<'_> {
47-
pub const BASE: Self = IndexSettingsConf { configure: |_| (), criterion: None };
48+
pub const BASE: Self = IndexSettingsConf { criterion: None };
4849
}
4950

5051
#[derive(Clone)]
@@ -99,7 +100,7 @@ pub fn base_setup_index(conf: &IndexConf) -> Index {
99100
builder.reset_criteria();
100101
builder.reset_stop_words();
101102

102-
// (conf.configure)(&mut builder);
103+
(conf.configure)(&mut builder);
103104

104105
builder.execute(|_| (), || false).unwrap();
105106
wtxn.commit().unwrap();
@@ -139,7 +140,6 @@ pub fn run_benches(
139140
let criterion = criterion.iter().map(|s| s.to_string()).collect();
140141
builder.set_criteria(criterion);
141142
}
142-
(index_settings_conf.configure)(&mut builder);
143143
builder.execute(|_| (), || false).unwrap();
144144
wtxn.commit().unwrap();
145145

0 commit comments

Comments
 (0)