fix the benches

This commit is contained in:
tamo 2021-04-13 14:26:08 +02:00 committed by Tamo
parent 4b78ef31b6
commit 136efd6b53
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
2 changed files with 19 additions and 6 deletions

View File

@ -18,8 +18,8 @@ fn bench_criterion(c: &mut criterion::Criterion) {
];
let default_criterion: Vec<String> = milli::default_criteria().iter().map(|criteria| criteria.to_string()).collect();
let default_criterion = default_criterion.iter().map(|s| s.as_str());
let asc_default: Vec<&str> = std::iter::once("asc").chain(default_criterion.clone()).collect();
let desc_default: Vec<&str> = std::iter::once("desc").chain(default_criterion.clone()).collect();
let asc_default: Vec<&str> = std::iter::once("asc(released-timestamp)").chain(default_criterion.clone()).collect();
let desc_default: Vec<&str> = std::iter::once("desc(released-timestamp)").chain(default_criterion.clone()).collect();
let confs = &[
utils::Conf {
@ -72,13 +72,13 @@ fn bench_criterion(c: &mut criterion::Criterion) {
utils::Conf {
group_name: "asc",
queries: songs_base_queries,
criterion: Some(&["asc"]),
criterion: Some(&["asc(released-timestamp)"]),
..utils::Conf::BASE_SONGS
},
utils::Conf {
group_name: "desc",
queries: songs_base_queries,
criterion: Some(&["desc"]),
criterion: Some(&["desc(released-timestamp)"]),
..utils::Conf::BASE_SONGS
},
utils::Conf {

View File

@ -40,6 +40,18 @@ impl Conf<'_> {
.map(|s| s.to_string())
.collect();
builder.set_searchable_fields(searchable_fields);
let faceted_fields = [
("released-timestamp", "integer"),
("duration-float", "float"),
("genre", "string"),
("country", "string"),
("artist", "string"),
]
.iter()
.map(|(a, b)| (a.to_string(), b.to_string()))
.collect();
builder.set_faceted_fields(faceted_fields);
}
pub const BASE: Self = Conf {
@ -54,7 +66,7 @@ impl Conf<'_> {
};
pub const BASE_SONGS: Self = Conf {
dataset: "smol-songs",
dataset: "smol-songs.csv",
configure: Self::songs_conf,
..Self::BASE
};
@ -97,7 +109,8 @@ pub fn base_setup(conf: &Conf) -> Index {
builder.update_format(UpdateFormat::Csv);
builder.index_documents_method(IndexDocumentsMethod::ReplaceDocuments);
// we called from cargo the current directory is supposed to be milli/milli
let reader = File::open(conf.dataset).unwrap();
let dataset_path = format!("benches/{}", conf.dataset);
let reader = File::open(&dataset_path).expect(&format!("could not find the dataset in: {}", &dataset_path));
builder.execute(reader, |_, _| ()).unwrap();
wtxn.commit().unwrap();