typos/benches/file.rs

140 lines
3.1 KiB
Rust
Raw Normal View History

2019-01-22 17:01:33 -05:00
#![feature(test)]
extern crate test;
mod data;
pub use assert_fs::prelude::*;
#[bench]
fn process_empty(b: &mut test::Bencher) {
let temp = assert_fs::TempDir::new().unwrap();
let sample_path = temp.child("sample");
sample_path.write_str(data::EMPTY).unwrap();
2019-07-03 21:22:36 -04:00
let corrections = typos::Dictionary::new();
2019-06-14 08:43:21 -04:00
b.iter(|| {
2019-07-03 21:22:36 -04:00
typos::process_file(
2019-06-14 08:43:21 -04:00
sample_path.path(),
&corrections,
true,
2019-07-18 22:20:45 -04:00
true,
true,
2019-07-13 22:14:06 -04:00
false,
2019-07-03 21:22:36 -04:00
typos::report::print_silent,
2019-06-14 08:43:21 -04:00
)
});
2019-01-22 17:01:33 -05:00
temp.close().unwrap();
}
#[bench]
fn process_no_tokens(b: &mut test::Bencher) {
let temp = assert_fs::TempDir::new().unwrap();
let sample_path = temp.child("sample");
sample_path.write_str(data::NO_TOKENS).unwrap();
2019-07-03 21:22:36 -04:00
let corrections = typos::Dictionary::new();
2019-06-14 08:43:21 -04:00
b.iter(|| {
2019-07-03 21:22:36 -04:00
typos::process_file(
2019-06-14 08:43:21 -04:00
sample_path.path(),
&corrections,
true,
2019-07-18 22:20:45 -04:00
true,
true,
2019-07-13 22:14:06 -04:00
false,
2019-07-03 21:22:36 -04:00
typos::report::print_silent,
2019-06-14 08:43:21 -04:00
)
});
2019-01-22 17:01:33 -05:00
temp.close().unwrap();
}
#[bench]
fn process_single_token(b: &mut test::Bencher) {
let temp = assert_fs::TempDir::new().unwrap();
let sample_path = temp.child("sample");
sample_path.write_str(data::SINGLE_TOKEN).unwrap();
2019-07-03 21:22:36 -04:00
let corrections = typos::Dictionary::new();
2019-06-14 08:43:21 -04:00
b.iter(|| {
2019-07-03 21:22:36 -04:00
typos::process_file(
2019-06-14 08:43:21 -04:00
sample_path.path(),
&corrections,
true,
2019-07-18 22:20:45 -04:00
true,
true,
2019-07-13 22:14:06 -04:00
false,
2019-07-03 21:22:36 -04:00
typos::report::print_silent,
2019-06-14 08:43:21 -04:00
)
});
2019-01-22 17:01:33 -05:00
temp.close().unwrap();
}
#[bench]
fn process_sherlock(b: &mut test::Bencher) {
let temp = assert_fs::TempDir::new().unwrap();
let sample_path = temp.child("sample");
sample_path.write_str(data::SHERLOCK).unwrap();
2019-07-03 21:22:36 -04:00
let corrections = typos::Dictionary::new();
2019-06-14 08:43:21 -04:00
b.iter(|| {
2019-07-03 21:22:36 -04:00
typos::process_file(
2019-06-14 08:43:21 -04:00
sample_path.path(),
&corrections,
true,
2019-07-18 22:20:45 -04:00
true,
true,
2019-07-13 22:14:06 -04:00
false,
2019-07-03 21:22:36 -04:00
typos::report::print_silent,
2019-06-14 08:43:21 -04:00
)
});
2019-01-22 17:01:33 -05:00
temp.close().unwrap();
}
#[bench]
fn process_code(b: &mut test::Bencher) {
let temp = assert_fs::TempDir::new().unwrap();
let sample_path = temp.child("sample");
sample_path.write_str(data::CODE).unwrap();
2019-07-03 21:22:36 -04:00
let corrections = typos::Dictionary::new();
2019-06-14 08:43:21 -04:00
b.iter(|| {
2019-07-03 21:22:36 -04:00
typos::process_file(
2019-06-14 08:43:21 -04:00
sample_path.path(),
&corrections,
true,
2019-07-18 22:20:45 -04:00
true,
true,
2019-07-13 22:14:06 -04:00
false,
2019-07-03 21:22:36 -04:00
typos::report::print_silent,
2019-06-14 08:43:21 -04:00
)
});
2019-01-22 17:01:33 -05:00
temp.close().unwrap();
}
#[bench]
fn process_corpus(b: &mut test::Bencher) {
let temp = assert_fs::TempDir::new().unwrap();
let sample_path = temp.child("sample");
sample_path.write_str(data::CORPUS).unwrap();
2019-07-03 21:22:36 -04:00
let corrections = typos::Dictionary::new();
2019-06-14 08:43:21 -04:00
b.iter(|| {
2019-07-03 21:22:36 -04:00
typos::process_file(
2019-06-14 08:43:21 -04:00
sample_path.path(),
&corrections,
true,
2019-07-18 22:20:45 -04:00
true,
true,
2019-07-13 22:14:06 -04:00
false,
2019-07-03 21:22:36 -04:00
typos::report::print_silent,
2019-06-14 08:43:21 -04:00
)
});
2019-01-22 17:01:33 -05:00
temp.close().unwrap();
}