Skip to content
Myr

main.rs

This file

Path

src/main.rs

72 lines · 1.9 KiB · Rust

Last changed by

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

History of this file

Take it

The walk stopped after 200 commits: lines older than ab5ae5f point at it.

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 1–6why, one step back
1#![cfg_attr(
2 all(windows, feature = "windows_process_extensions_main_thread_handle"),3 feature(windows_process_extensions_main_thread_handle)4)]56use std::env;

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

line 7why, one step back
7use std::io::{self, Write};

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 8–11why, one step back
8
9use benchmark::scheduler::Scheduler;10use cli::get_cli_arguments;11use command::Commands;

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

line 12why, one step back
12use error::ConsoleOutputError;

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 13–23why, one step back
13use export::ExportManager;
14use options::Options;1516use anyhow::Result;17use colored::*;1819pub mod benchmark;20pub mod cli;21pub mod command;22pub mod error;23pub mod export;

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 24why, one step back
24pub mod metric;

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 25–28why, one step back
25pub mod options;
26pub mod outlier_detection;27pub mod output;28pub mod parameter;

Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010

line 29why, one step back
29pub mod quantity;

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 30–38why, one step back
30pub mod timer;
31pub mod util;3233fn run() -> Result<()> {34 // Enabled ANSI colors on Windows 1035 #[cfg(windows)]36 colored::control::set_virtual_terminal(true).unwrap();3738 let cli_arguments = get_cli_arguments(env::args_os());

Multiple output policiesDavid Peterbefore adoption99d24b7

line 39why, one step back
39 let mut options = Options::from_cli_arguments(&cli_arguments)?;

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

line 40why, one step back
40 let commands = Commands::from_cli_arguments(&cli_arguments)?;

Merge pull request #950 from Likio3000/codex/preserve-exports-on-invalid-optionsDavid Peterbefore adoptiond3d67fc

lines 41–42why, one step back
41 options.validate_against_command_list(&commands)?;
42

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 43why, one step back
43 let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.metrics[0])?;

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 44–51why, one step back
44
45 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);46 scheduler.run_benchmarks()?;47 scheduler.final_export()?;4849 Ok(())50}51

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

lines 52–57why, one step back
52fn caused_by_broken_console_pipe(error: &anyhow::Error) -> bool {
53 error54 .downcast_ref::<ConsoleOutputError>()55 .is_some_and(|e| e.0.kind() == io::ErrorKind::BrokenPipe)56}57

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 58–61why, one step back
58fn main() {
59 match run() {60 Ok(_) => {}61 Err(e) => {

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

lines 62–68why, one step back
62 // Exit quietly when a reader stops consuming console output early.
63 if caused_by_broken_console_pipe(&e) {64 std::process::exit(0);65 }66 // The write to stderr can itself fail if stderr is closed; the67 // error message cannot be shown in that case anyway.68 let _ = writeln!(io::stderr(), "{} {:#}", "Error:".red(), e);

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 69–72why, one step back
69 std::process::exit(1);
70 }71 }72}