Skip to content

Commit

Permalink
bench(cli): Callgrind benchmark with calliper
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 2, 2023
1 parent 8a7996b commit ef3addb
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions crates/typos-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ encoding_rs = "0.8.32"
assert_fs = "1.0"
trycmd = "0.14.16"
criterion = "0.5"
calliper = { git = "https://github.com/osiewicz/calliper.git" }

[[bench]]
name = "checks"
Expand All @@ -98,3 +99,7 @@ harness = false
[[bench]]
name = "tokenize"
harness = false

[[bench]]
name = "cli"
harness = false
17 changes: 17 additions & 0 deletions crates/typos-cli/benches/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use calliper::{Runner, Scenario, ScenarioConfig};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let bin = std::path::Path::new(env!("CARGO_BIN_EXE_typos"));

let mut check_words_csv = std::process::Command::new(bin);
check_words_csv.arg("../typos-dict/assets/words.csv");

let runner = Runner::default().config(ScenarioConfig::default().branch_sim(true));
let benches = [Scenario::new_with_command(check_words_csv).name("words.csv")];
if let Some(results) = runner.run(&benches)? {
for res in results.into_iter() {
println!("{}", res.parse());
}
}
Ok(())
}

0 comments on commit ef3addb

Please sign in to comment.