2019-01-22 17:01:33 -05:00
|
|
|
#![feature(test)]
|
|
|
|
|
|
|
|
extern crate test;
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn load_corrections(b: &mut test::Bencher) {
|
2019-04-16 19:27:55 -04:00
|
|
|
b.iter(|| defenestrate::Dictionary::new());
|
2019-01-22 17:01:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-06-16 00:21:40 -04:00
|
|
|
fn correct_word_hit(b: &mut test::Bencher) {
|
2019-04-16 19:27:55 -04:00
|
|
|
let corrections = defenestrate::Dictionary::new();
|
2019-06-16 00:21:40 -04:00
|
|
|
let input = defenestrate::tokens::Word::new("successs", 0).unwrap();
|
2019-06-24 23:45:30 -04:00
|
|
|
assert_eq!(
|
|
|
|
corrections.correct_word(input),
|
|
|
|
Some(std::borrow::Cow::Borrowed("successes"))
|
|
|
|
);
|
2019-06-16 00:21:40 -04:00
|
|
|
b.iter(|| corrections.correct_word(input));
|
2019-01-22 17:01:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-06-16 00:21:40 -04:00
|
|
|
fn correct_word_miss(b: &mut test::Bencher) {
|
2019-04-16 19:27:55 -04:00
|
|
|
let corrections = defenestrate::Dictionary::new();
|
2019-06-16 00:21:40 -04:00
|
|
|
let input = defenestrate::tokens::Word::new("success", 0).unwrap();
|
|
|
|
assert_eq!(corrections.correct_word(input), None);
|
|
|
|
b.iter(|| corrections.correct_word(input));
|
2019-01-22 17:01:33 -05:00
|
|
|
}
|