mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
ab4a5bbdaf
The goal is to be as accepting and unobtrusive to new code bases as possible. To this end, we correct typos into the closest english dialect. If someone wants to opt-in, they can have typos correct to a specific english dialect. Fixes #52 Fixes #22
27 lines
824 B
Rust
27 lines
824 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),
|
|
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_empty());
|
|
b.iter(|| corrections.correct_word(input));
|
|
}
|