fn bench_construct(c: &mut Criterion) {
c.bench_function("construct", |b| {
b.iter(|| { let dic = unsafe { mapped_hyph::load_file(DIC_PATH) }
.expect(&format!("failed to load dictionary {}", DIC_PATH)); let _ = Hyphenator::new(black_box(&*dic));
})
});
}
fn bench_find_hyphen_values(c: &mut Criterion) { // XXX: Should we copy this file to the crate to ensure reproducability? let data = fs::read_to_string("/usr/share/dict/words").expect("File reading failed."); let words: Vec<&str> = data.lines().take(SAMPLE_SIZE).collect();
let dic = unsafe { mapped_hyph::load_file(DIC_PATH) }
.expect(&format!("failed to load dictionary {}", DIC_PATH)); let hyph = Hyphenator::new(&*dic);
c.bench_with_input(
BenchmarkId::new("bench_word", SAMPLE_SIZE),
&words,
|b, words| {
b.iter(|| { letmut values: Vec<u8> = vec![0; 1000]; for w in words {
hyph.find_hyphen_values(&w, &mut values);
}
});
},
);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.