mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-27 10:02:09 -05:00
527b9837b4
Switching `valid-*` to just `*` where you map typo to correction, with support for always-valid and never-valid. Fixes #9
29 lines
879 B
Rust
29 lines
879 B
Rust
#![feature(test)]
|
|
|
|
extern crate test;
|
|
|
|
#[bench]
|
|
fn load_corrections(b: &mut test::Bencher) {
|
|
b.iter(|| typos_cli::dict::BuiltIn::new(Default::default()));
|
|
}
|
|
|
|
#[bench]
|
|
fn correct_word_hit(b: &mut test::Bencher) {
|
|
let corrections = typos_cli::dict::BuiltIn::new(Default::default());
|
|
let input = typos::tokens::Word::new("successs", 0).unwrap();
|
|
assert_eq!(
|
|
corrections.correct_word(input),
|
|
Some(typos::Status::Corrections(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(Default::default());
|
|
let input = typos::tokens::Word::new("success", 0).unwrap();
|
|
assert!(corrections.correct_word(input).is_none());
|
|
b.iter(|| corrections.correct_word(input));
|
|
}
|