Skip to content

Commit ef3addb

Browse files
committed
bench(cli): Callgrind benchmark with calliper
1 parent 8a7996b commit ef3addb

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

Cargo.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/typos-cli/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ encoding_rs = "0.8.32"
8686
assert_fs = "1.0"
8787
trycmd = "0.14.16"
8888
criterion = "0.5"
89+
calliper = { git = "https://github.com/osiewicz/calliper.git" }
8990

9091
[[bench]]
9192
name = "checks"
@@ -98,3 +99,7 @@ harness = false
9899
[[bench]]
99100
name = "tokenize"
100101
harness = false
102+
103+
[[bench]]
104+
name = "cli"
105+
harness = false

crates/typos-cli/benches/cli.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use calliper::{Runner, Scenario, ScenarioConfig};
2+
3+
fn main() -> Result<(), Box<dyn std::error::Error>> {
4+
let bin = std::path::Path::new(env!("CARGO_BIN_EXE_typos"));
5+
6+
let mut check_words_csv = std::process::Command::new(bin);
7+
check_words_csv.arg("../typos-dict/assets/words.csv");
8+
9+
let runner = Runner::default().config(ScenarioConfig::default().branch_sim(true));
10+
let benches = [Scenario::new_with_command(check_words_csv).name("words.csv")];
11+
if let Some(results) = runner.run(&benches)? {
12+
for res in results.into_iter() {
13+
println!("{}", res.parse());
14+
}
15+
}
16+
Ok(())
17+
}

0 commit comments

Comments
 (0)