mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
24 lines
732 B
Rust
24 lines
732 B
Rust
#![feature(test)]
|
|
|
|
extern crate test;
|
|
|
|
#[bench]
|
|
fn load_corrections(b: &mut test::Bencher) {
|
|
b.iter(|| defenestrate::Dictionary::new());
|
|
}
|
|
|
|
#[bench]
|
|
fn correct_word_hit(b: &mut test::Bencher) {
|
|
let corrections = defenestrate::Dictionary::new();
|
|
let input = defenestrate::tokens::Word::new("successs", 0).unwrap();
|
|
assert_eq!(corrections.correct_word(input), Some("successes"));
|
|
b.iter(|| corrections.correct_word(input));
|
|
}
|
|
|
|
#[bench]
|
|
fn correct_word_miss(b: &mut test::Bencher) {
|
|
let corrections = defenestrate::Dictionary::new();
|
|
let input = defenestrate::tokens::Word::new("success", 0).unwrap();
|
|
assert_eq!(corrections.correct_word(input), None);
|
|
b.iter(|| corrections.correct_word(input));
|
|
}
|