diff options
Diffstat (limited to 'src/bin/obnam-benchmark.rs')
-rw-r--r-- | src/bin/obnam-benchmark.rs | 15 |
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(()) } } |