2018-06-24 21:10:13 +08:00
|
|
|
#![feature(test)]
|
|
|
|
|
|
|
|
extern crate test;
|
|
|
|
extern crate fst;
|
|
|
|
extern crate raptor;
|
|
|
|
|
|
|
|
use fst::Streamer;
|
2018-06-24 21:36:24 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-06-24 21:36:24 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|