typos/benches/corrections.rs
2019-07-03 19:22:36 -06:00

27 lines
747 B
Rust

#![feature(test)]
extern crate test;
#[bench]
fn load_corrections(b: &mut test::Bencher) {
b.iter(|| typos::Dictionary::new());
}
#[bench]
fn correct_word_hit(b: &mut test::Bencher) {
let corrections = typos::Dictionary::new();
let input = typos::tokens::Word::new("successs", 0).unwrap();
assert_eq!(
corrections.correct_word(input),
Some(std::borrow::Cow::Borrowed("successes"))
);
b.iter(|| corrections.correct_word(input));
}
#[bench]
fn correct_word_miss(b: &mut test::Bencher) {
let corrections = typos::Dictionary::new();
let input = typos::tokens::Word::new("success", 0).unwrap();
assert_eq!(corrections.correct_word(input), None);
b.iter(|| corrections.correct_word(input));
}