-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bench(cli): Callgrind benchmark with calliper
- Loading branch information
Showing
9 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use calliper::{Runner, Scenario, ScenarioConfig}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let runner = Runner::default().config(ScenarioConfig::default().branch_sim(true)); | ||
let benches = [ | ||
Scenario::new_with_command(cmd(&["benches/data/empty.txt"])).name("empty.txt"), | ||
Scenario::new_with_command(cmd(&["benches/data/no_tokens.txt"])).name("no_tokens.txt"), | ||
Scenario::new_with_command(cmd(&["benches/data/single_token.txt"])) | ||
.name("single_token.txt"), | ||
Scenario::new_with_command(cmd(&["benches/data/sherlock.txt"])).name("sherlock.txt"), | ||
Scenario::new_with_command(cmd(&["benches/data/code.txt"])).name("code.txt"), | ||
Scenario::new_with_command(cmd(&["../typos-dict/assets/words.csv"])).name("words.csv"), | ||
]; | ||
if let Some(results) = runner.run(&benches)? { | ||
for res in results.into_iter() { | ||
println!("{}", res.parse()); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn cmd(args: &[&str]) -> std::process::Command { | ||
let bin = std::path::Path::new(env!("CARGO_BIN_EXE_typos")); | ||
|
||
let mut cmd = std::process::Command::new(bin); | ||
cmd.args(args); | ||
|
||
cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extern crate snap; | ||
use std::io; | ||
fn main() { | ||
let stdin = io::stdin(); | ||
let stdout = io::stdout(); | ||
// Wrap the stdin reader in a Snappy reader. | ||
let mut rdr = snap::Reader::new(stdin.lock()); | ||
let mut wtr = stdout.lock(); | ||
io::copy(&mut rdr, &mut wtr).expect(\"I/O operation failed\"); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
For the Doctor Watsons of this world, as opposed to the Sherlock | ||
Holmeses, success in the province of detective work must always | ||
be, to a very large extent, the result of luck. Sherlock Holmes | ||
can extract a clew from a wisp of straw or a flake of cigar ash; | ||
but Doctor Watson has to have it taken out for him and dusted, | ||
and exhibited clearly, with a label attached.\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
success |