#![deny(clippy::all)]
use structopt::StructOpt;
mod bench;
mod cli;
mod format;
use crate::bench::Results;
use crate::cli::Config;
use crate::format::{DatFormat, Format, StdoutFormat};
fn main() {
let config = Config::from_args();
let mut loaders = bench::find_benchmarks(&config.benchmarks);
let results: Vec<Results> = loaders
.drain(..)
.filter_map(|loader| loader.load(config.min_bytes).ok())
.map(|bench| bench.run(config.warmup, config.max_secs, config.max_samples))
.collect();
if !config.silent {
StdoutFormat.format(&results);
}
if let Some(path) = config.dat {
DatFormat::new(path).format(&results);
}
}