meilisearch/raptor-search/benches/main.rs

30 lines
738 B
Rust
Raw Normal View History

2018-06-24 21:10:13 +08:00
#![feature(test)]
extern crate test;
extern crate fst;
extern crate raptor;
use fst::Streamer;
use raptor::{load_map, RankedStream, LevBuilder};
2018-06-24 21:10:13 +08:00
#[bench]
fn chauve_souris(b: &mut test::Bencher) {
let lev_builder = LevBuilder::new();
let map = load_map("map.fst", "values.vecs").unwrap();
let query = "chauve souris";
b.iter(|| {
let mut automatons = Vec::new();
for query in query.split_whitespace() {
let lev = lev_builder.build_automaton(query);
automatons.push(lev);
}
let mut stream = RankedStream::new(&map, &map.values(), automatons, 20);
2018-06-24 21:10:13 +08:00
while let Some(document_id) = stream.next() {
test::black_box(document_id);
}
})
}