euv-performance 0.46.1

Reproducible CPU, layout, rasterization, and allocation benchmarks for the cross-platform euv runtime.
Documentation
use std::env;

use euv_performance::{
    BENCH_FLAG_FILTER, BENCH_FLAG_JSON, BENCH_FLAG_OBSERVABILITY_JSON, BENCH_FLAG_STRESS_MATRIX,
    BenchReport, OBSERVABILITY_DEFAULT_COMMIT, OBSERVABILITY_DEFAULT_PROFILE,
    ObservabilityReportV1, StressMatrixReport, emit_stress_observability_report,
    format_bench_report, format_stress_matrix_report, observability_report_to_json, report_to_json,
    run_filtered_benchmark_suite, run_filtered_stress_matrix, stress_matrix_to_json,
};

/// Body of the `main` free function.
fn main() {
    let args: Vec<String> = env::args().collect();
    let mut filter: Option<String> = None;
    let mut stress_matrix: bool = false;
    let mut emit_json: bool = false;
    let mut emit_observability: bool = false;
    let mut idx: usize = 1;
    while idx < args.len() {
        let arg: &str = args[idx].as_str();
        if arg == BENCH_FLAG_FILTER {
            if let Some(next_val) = args.get(idx + 1) {
                filter = Some(next_val.clone());
                idx += 1;
            }
        } else if let Some(rest) = arg.strip_prefix(BENCH_FLAG_FILTER)
            && let Some(val) = rest.strip_prefix('=')
            && !val.is_empty()
        {
            filter = Some(val.to_string());
        } else if arg == BENCH_FLAG_STRESS_MATRIX {
            stress_matrix = true;
        } else if arg == BENCH_FLAG_JSON {
            emit_json = true;
        } else if arg == BENCH_FLAG_OBSERVABILITY_JSON {
            emit_observability = true;
        }
        idx += 1;
    }
    if emit_observability {
        let report: StressMatrixReport = run_filtered_stress_matrix(filter.as_deref());
        let obs: ObservabilityReportV1 = emit_stress_observability_report(
            &report,
            OBSERVABILITY_DEFAULT_COMMIT,
            OBSERVABILITY_DEFAULT_PROFILE,
        );
        println!("{}", observability_report_to_json(&obs));
    } else if stress_matrix {
        let report: StressMatrixReport = run_filtered_stress_matrix(filter.as_deref());
        if emit_json {
            println!("{}", stress_matrix_to_json(&report));
        } else {
            print!("{}", format_stress_matrix_report(&report));
        }
    } else {
        let report: BenchReport = run_filtered_benchmark_suite(filter.as_deref());
        if emit_json {
            println!("{}", report_to_json(&report));
        } else {
            print!("{}", format_bench_report(&report));
        }
    }
}