typos/benches/corrections.rs
Ed Page bc1302f01b feat: Support multiple, valid corrections
Some of the other spell checkers already do this. While I've not checked
where we might need it for our dictionary, this will be important for
dialects.
2020-07-04 20:52:48 -05:00

27 lines
770 B
Rust

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