mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-26 17:42:15 -05:00
27 lines
753 B
Rust
27 lines
753 B
Rust
#![feature(test)]
|
|
|
|
extern crate test;
|
|
|
|
#[bench]
|
|
fn load_corrections(b: &mut test::Bencher) {
|
|
b.iter(|| typos_dict::BuiltIn::new());
|
|
}
|
|
|
|
#[bench]
|
|
fn correct_word_hit(b: &mut test::Bencher) {
|
|
let corrections = typos_dict::BuiltIn::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_dict::BuiltIn::new();
|
|
let input = typos::tokens::Word::new("success", 0).unwrap();
|
|
assert_eq!(corrections.correct_word(input), None);
|
|
b.iter(|| corrections.correct_word(input));
|
|
}
|