typos/benches/corrections.rs

28 lines
770 B
Rust
Raw Normal View History

2019-01-22 17:01:33 -05:00
#![feature(test)]
extern crate test;
#[bench]
fn load_corrections(b: &mut test::Bencher) {
2019-10-30 09:19:27 -04:00
b.iter(|| typos_cli::dict::BuiltIn::new());
2019-01-22 17:01:33 -05:00
}
#[bench]
fn correct_word_hit(b: &mut test::Bencher) {
2019-10-30 09:19:27 -04:00
let corrections = typos_cli::dict::BuiltIn::new();
2019-07-03 21:22:36 -04:00
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));
2019-01-22 17:01:33 -05:00
}
#[bench]
fn correct_word_miss(b: &mut test::Bencher) {
2019-10-30 09:19:27 -04:00
let corrections = typos_cli::dict::BuiltIn::new();
2019-07-03 21:22:36 -04:00
let input = typos::tokens::Word::new("success", 0).unwrap();
assert!(corrections.correct_word(input).is_empty());
b.iter(|| corrections.correct_word(input));
2019-01-22 17:01:33 -05:00
}