summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-16 11:21:34 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-16 11:21:34 +0200
commit8f15eb79af7cba799a0f1286f277bd49353b5ca3 (patch)
tree445ad4217bb3719a9b0d858ccb1b2af03d776b80
parent1ad4e5d867cf9b040de48371cce55bdb3ad001ea (diff)
downloadobnam-benchmark-8f15eb79af7cba799a0f1286f277bd49353b5ca3.tar.gz
feat: allow report to write to named file
Sponsored-by: author
-rw-r--r--src/bin/obnam-benchmark.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/bin/obnam-benchmark.rs b/src/bin/obnam-benchmark.rs
index 8b75229..db04d0a 100644
--- a/src/bin/obnam-benchmark.rs
+++ b/src/bin/obnam-benchmark.rs
@@ -182,6 +182,10 @@ impl Steps {
#[derive(Debug, StructOpt)]
struct Report {
+ /// File where to write the report. Stdout by default.
+ #[structopt(short, long, parse(from_os_str))]
+ output: Option<PathBuf>,
+
/// Names of the results file for which to produce a report.
#[structopt(parse(from_os_str))]
filenames: Vec<PathBuf>,
@@ -190,11 +194,16 @@ struct Report {
impl Report {
fn run(&self) -> anyhow::Result<()> {
info!("Reporting results");
- let mut report = Reporter::default();
+ let mut reporter = Reporter::default();
for filename in self.filenames.iter() {
- report.push(SuiteMeasurements::from_file(filename)?);
+ reporter.push(SuiteMeasurements::from_file(filename)?);
+ }
+ if let Some(output) = &self.output {
+ let mut file = File::create(output)?;
+ reporter.write(&mut file)?;
+ } else {
+ reporter.write(&mut std::io::stdout())?;
}
- report.write(&mut std::io::stdout())?;
Ok(())
}
}