2019-01-22 15:01:33 -07:00
|
|
|
#![feature(test)]
|
|
|
|
|
|
|
|
extern crate test;
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn load_corrections(b: &mut test::Bencher) {
|
2020-05-27 20:46:41 -05:00
|
|
|
b.iter(|| typos_cli::dict::BuiltIn::new(Default::default()));
|
2019-01-22 15:01:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-06-15 22:21:40 -06:00
|
|
|
fn correct_word_hit(b: &mut test::Bencher) {
|
2020-05-27 20:46:41 -05:00
|
|
|
let corrections = typos_cli::dict::BuiltIn::new(Default::default());
|
2019-07-03 19:22:36 -06:00
|
|
|
let input = typos::tokens::Word::new("successs", 0).unwrap();
|
2019-06-24 21:45:30 -06:00
|
|
|
assert_eq!(
|
|
|
|
corrections.correct_word(input),
|
2020-10-24 21:17:16 -05:00
|
|
|
Some(typos::Status::Corrections(vec![
|
|
|
|
std::borrow::Cow::Borrowed("successes")
|
|
|
|
]))
|
2019-06-24 21:45:30 -06:00
|
|
|
);
|
2019-06-15 22:21:40 -06:00
|
|
|
b.iter(|| corrections.correct_word(input));
|
2019-01-22 15:01:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-06-15 22:21:40 -06:00
|
|
|
fn correct_word_miss(b: &mut test::Bencher) {
|
2020-05-27 20:46:41 -05:00
|
|
|
let corrections = typos_cli::dict::BuiltIn::new(Default::default());
|
2019-07-03 19:22:36 -06:00
|
|
|
let input = typos::tokens::Word::new("success", 0).unwrap();
|
2020-10-24 21:17:16 -05:00
|
|
|
assert!(corrections.correct_word(input).is_none());
|
2019-06-15 22:21:40 -06:00
|
|
|
b.iter(|| corrections.correct_word(input));
|
2019-01-22 15:01:33 -07:00
|
|
|
}
|