diff options
Diffstat (limited to 'src/bin/obnam-benchmark.rs')
-rw-r--r-- | src/bin/obnam-benchmark.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/obnam-benchmark.rs b/src/bin/obnam-benchmark.rs index 0ad8491..76ab620 100644 --- a/src/bin/obnam-benchmark.rs +++ b/src/bin/obnam-benchmark.rs @@ -1,3 +1,4 @@ +use log::{debug, error, info}; use obnam_benchmark::result::Result; use obnam_benchmark::specification::Specification; use obnam_benchmark::state::State; @@ -7,14 +8,20 @@ use std::process::exit; use structopt::StructOpt; fn main() { + pretty_env_logger::init_custom_env("OBNAM_BENCHMARK_LOG"); + info!("obnam-benchmark starts"); if let Err(err) = real_main() { eprintln!("ERROR: {}", err); + error!("{}", err); exit(1); } + info!("obnam-benchmark ends successfully"); } fn real_main() -> anyhow::Result<()> { + debug!("parsing command line"); let opt = Opt::from_args(); + debug!("parsed: {:#?}", opt); match opt.cmd { Command::Run(x) => x.run()?, @@ -52,6 +59,7 @@ struct Run { impl Run { fn run(&self) -> anyhow::Result<()> { + info!("running benchmarks from {}", self.spec.display()); let spec = Specification::from_file(&self.spec)?; let mut state = State::new()?; let mut result = Result::default(); @@ -60,6 +68,7 @@ impl Run { result.push(m); } } + debug!("writing results to {}", self.output.display()); let output = File::create(&self.output)?; serde_json::to_writer_pretty(&output, &result)?; Ok(()) @@ -79,9 +88,12 @@ struct Spec { impl Spec { fn run(&self) -> anyhow::Result<()> { + info!("dumping specification file as JSON"); + debug!("reading specification from {}", self.spec.display()); let input = File::open(&self.spec)?; let spec: Specification = serde_yaml::from_reader(&input)?; + debug!("writing specification as JSON to {}", self.output.display()); let output = File::create(&self.output)?; serde_json::to_writer(&output, &spec)?; |