Files
hyperfine/src/main.rs
T

56 lines
1.3 KiB
Rust
Raw Normal View History

2022-08-08 16:37:39 +02:00
#![cfg_attr(
all(windows, feature = "windows_process_extensions_main_thread_handle"),
feature(windows_process_extensions_main_thread_handle)
)]
2018-03-24 18:30:52 -04:00
use std::env;
2018-01-13 16:50:02 +01:00
2022-02-07 21:03:23 +01:00
use benchmark::scheduler::Scheduler;
2022-02-22 14:04:07 +01:00
use cli::get_cli_arguments;
2022-02-06 21:02:15 +01:00
use command::Commands;
2022-02-06 18:22:55 +01:00
use export::ExportManager;
2022-02-06 20:10:40 +01:00
use options::Options;
2018-01-14 10:48:47 +01:00
2022-02-06 20:10:40 +01:00
use anyhow::Result;
2022-02-06 19:49:31 +01:00
use colored::*;
pub mod benchmark;
2022-02-22 14:04:07 +01:00
pub mod cli;
2022-02-06 19:49:31 +01:00
pub mod command;
pub mod error;
pub mod export;
pub mod options;
pub mod outlier_detection;
pub mod output;
pub mod parameter;
pub mod timer;
2022-02-06 20:01:41 +01:00
pub mod util;
2018-01-14 11:41:27 +13:00
2022-02-06 17:44:28 +01:00
fn run() -> Result<()> {
// Enabled ANSI colors on Windows 10
#[cfg(windows)]
colored::control::set_virtual_terminal(true).unwrap();
2022-02-06 21:02:15 +01:00
let cli_arguments = get_cli_arguments(env::args_os());
let options = Options::from_cli_arguments(&cli_arguments)?;
let commands = Commands::from_cli_arguments(&cli_arguments)?;
let export_manager = ExportManager::from_cli_arguments(&cli_arguments)?;
2018-03-24 18:30:52 -04:00
2022-02-07 21:03:23 +01:00
options.validate_against_command_list(&commands)?;
let mut scheduler = Scheduler::new(&commands, &options, &export_manager);
scheduler.run_benchmarks()?;
scheduler.print_relative_speed_comparison();
Ok(())
2022-02-06 17:44:28 +01:00
}
2018-03-24 18:30:52 -04:00
2022-02-06 17:44:28 +01:00
fn main() {
match run() {
2020-10-16 10:47:26 +02:00
Ok(_) => {}
2022-02-06 17:44:28 +01:00
Err(e) => {
eprintln!("{} {:#}", "Error:".red(), e);
std::process::exit(1);
}
2018-03-24 18:30:52 -04:00
}
}