2019-01-22 17:01:33 -05:00
|
|
|
#![feature(test)]
|
|
|
|
|
|
|
|
extern crate test;
|
|
|
|
|
|
|
|
mod data;
|
|
|
|
|
|
|
|
pub use assert_fs::prelude::*;
|
|
|
|
|
|
|
|
#[bench]
|
2019-10-25 17:17:24 -04:00
|
|
|
fn check_file_empty(b: &mut test::Bencher) {
|
2019-01-22 17:01:33 -05:00
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
let sample_path = temp.child("sample");
|
|
|
|
sample_path.write_str(data::EMPTY).unwrap();
|
|
|
|
|
2019-08-08 11:24:50 -04:00
|
|
|
let corrections = typos_dict::BuiltIn::new();
|
2019-07-25 09:45:16 -04:00
|
|
|
let parser = typos::tokens::Parser::new();
|
2019-07-27 21:20:02 -04:00
|
|
|
let checks = typos::checks::CheckSettings::new().build(&corrections, &parser);
|
2019-07-31 23:01:09 -04:00
|
|
|
b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent));
|
2019-01-22 17:01:33 -05:00
|
|
|
|
|
|
|
temp.close().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-10-25 17:17:24 -04:00
|
|
|
fn check_file_no_tokens(b: &mut test::Bencher) {
|
2019-01-22 17:01:33 -05:00
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
let sample_path = temp.child("sample");
|
|
|
|
sample_path.write_str(data::NO_TOKENS).unwrap();
|
|
|
|
|
2019-08-08 11:24:50 -04:00
|
|
|
let corrections = typos_dict::BuiltIn::new();
|
2019-07-25 09:45:16 -04:00
|
|
|
let parser = typos::tokens::Parser::new();
|
2019-07-27 21:20:02 -04:00
|
|
|
let checks = typos::checks::CheckSettings::new().build(&corrections, &parser);
|
2019-07-31 23:01:09 -04:00
|
|
|
b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent));
|
2019-01-22 17:01:33 -05:00
|
|
|
|
|
|
|
temp.close().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-10-25 17:17:24 -04:00
|
|
|
fn check_file_single_token(b: &mut test::Bencher) {
|
2019-01-22 17:01:33 -05:00
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
let sample_path = temp.child("sample");
|
|
|
|
sample_path.write_str(data::SINGLE_TOKEN).unwrap();
|
|
|
|
|
2019-08-08 11:24:50 -04:00
|
|
|
let corrections = typos_dict::BuiltIn::new();
|
2019-07-25 09:45:16 -04:00
|
|
|
let parser = typos::tokens::Parser::new();
|
2019-07-27 21:20:02 -04:00
|
|
|
let checks = typos::checks::CheckSettings::new().build(&corrections, &parser);
|
2019-07-31 23:01:09 -04:00
|
|
|
b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent));
|
2019-01-22 17:01:33 -05:00
|
|
|
|
|
|
|
temp.close().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-10-25 17:17:24 -04:00
|
|
|
fn check_file_sherlock(b: &mut test::Bencher) {
|
2019-01-22 17:01:33 -05:00
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
let sample_path = temp.child("sample");
|
|
|
|
sample_path.write_str(data::SHERLOCK).unwrap();
|
|
|
|
|
2019-08-08 11:24:50 -04:00
|
|
|
let corrections = typos_dict::BuiltIn::new();
|
2019-07-25 09:45:16 -04:00
|
|
|
let parser = typos::tokens::Parser::new();
|
2019-07-27 21:20:02 -04:00
|
|
|
let checks = typos::checks::CheckSettings::new().build(&corrections, &parser);
|
2019-07-31 23:01:09 -04:00
|
|
|
b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent));
|
2019-01-22 17:01:33 -05:00
|
|
|
|
|
|
|
temp.close().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-10-25 17:17:24 -04:00
|
|
|
fn check_file_code(b: &mut test::Bencher) {
|
2019-01-22 17:01:33 -05:00
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
let sample_path = temp.child("sample");
|
|
|
|
sample_path.write_str(data::CODE).unwrap();
|
|
|
|
|
2019-08-08 11:24:50 -04:00
|
|
|
let corrections = typos_dict::BuiltIn::new();
|
2019-07-25 09:45:16 -04:00
|
|
|
let parser = typos::tokens::Parser::new();
|
2019-07-27 21:20:02 -04:00
|
|
|
let checks = typos::checks::CheckSettings::new().build(&corrections, &parser);
|
2019-07-31 23:01:09 -04:00
|
|
|
b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent));
|
2019-01-22 17:01:33 -05:00
|
|
|
|
|
|
|
temp.close().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-10-25 17:17:24 -04:00
|
|
|
fn check_file_corpus(b: &mut test::Bencher) {
|
2019-01-22 17:01:33 -05:00
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
let sample_path = temp.child("sample");
|
|
|
|
sample_path.write_str(data::CORPUS).unwrap();
|
|
|
|
|
2019-08-08 11:24:50 -04:00
|
|
|
let corrections = typos_dict::BuiltIn::new();
|
2019-07-25 09:45:16 -04:00
|
|
|
let parser = typos::tokens::Parser::new();
|
2019-07-27 21:20:02 -04:00
|
|
|
let checks = typos::checks::CheckSettings::new().build(&corrections, &parser);
|
2019-07-31 23:01:09 -04:00
|
|
|
b.iter(|| checks.check_file(sample_path.path(), true, typos::report::print_silent));
|
2019-01-22 17:01:33 -05:00
|
|
|
|
|
|
|
temp.close().unwrap();
|
|
|
|
}
|