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

Commit e2e4aee

Browse files
committed
Fix search benchmarks that don't contain queries
1 parent a08d492 commit e2e4aee

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

benchmarks/benches/utils.rs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -147,30 +147,33 @@ pub fn run_benches(
147147
let name = format!("{}: {}", file_name, search_conf.group_name);
148148
let _bench_criterion = c.bench_function(&name, |b| {
149149
b.iter(|| {
150-
for &query in search_conf.queries.iter() {
151-
let rtxn = index.read_txn().unwrap();
152-
let mut search = index.search(&rtxn);
153-
search
154-
.query(query)
155-
.terms_matching_strategy(TermsMatchingStrategy::default());
156-
if let Some(filter) = search_conf.filter {
157-
let filter = Filter::from_str(filter).unwrap().unwrap();
158-
search.filter(filter);
159-
}
160-
if let Some(sort) = &search_conf.sort {
161-
let sort = sort.iter().map(|sort| sort.parse().unwrap()).collect();
162-
search.sort_criteria(sort);
163-
}
164-
if let Some(limit) = search_conf.limit {
165-
search.limit(limit);
166-
}
167-
if let Some(offset) = search_conf.offset {
168-
search.offset(offset);
169-
}
170-
search.criterion_implementation_strategy(
171-
search_conf.criterion_implementation_strategy,
172-
);
150+
let rtxn = index.read_txn().unwrap();
151+
let mut search = index.search(&rtxn);
152+
search.terms_matching_strategy(TermsMatchingStrategy::default());
153+
if let Some(filter) = search_conf.filter {
154+
let filter = Filter::from_str(filter).unwrap().unwrap();
155+
search.filter(filter);
156+
}
157+
if let Some(sort) = &search_conf.sort {
158+
let sort = sort.iter().map(|sort| sort.parse().unwrap()).collect();
159+
search.sort_criteria(sort);
160+
}
161+
if let Some(limit) = search_conf.limit {
162+
search.limit(limit);
163+
}
164+
if let Some(offset) = search_conf.offset {
165+
search.offset(offset);
166+
}
167+
search.criterion_implementation_strategy(
168+
search_conf.criterion_implementation_strategy,
169+
);
170+
if search_conf.queries.is_empty() {
173171
let _ids = search.execute().unwrap();
172+
} else {
173+
for &query in search_conf.queries.iter() {
174+
search.query(query);
175+
let _ids = search.execute().unwrap();
176+
}
174177
}
175178
});
176179
});

0 commit comments

Comments
 (0)