Skip to content
Myr

benchmark_result.rs

This file

Path

src/benchmark/benchmark_result.rs

51 lines · 1.8 KiB · Rust

Last changed by

Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02

History of this file

Take it

1use std::collections::BTreeMap;23use serde::Serialize;45use crate::benchmark::measurement::Measurements;67/// Parameter value8#[derive(Debug, Default, Clone, Serialize, PartialEq)]9pub struct Parameter {10    pub value: String,11}1213/// Meta data and performance metrics for a single benchmark14#[derive(Debug, Default, Clone, Serialize, PartialEq)]15pub struct BenchmarkResult {16    /// The command line being benchmarked, after parameter substitution.17    /// For example, `sleep {duration}` with `duration=1` becomes `sleep 1`,18    /// regardless of any custom name.19    pub command: String,2021    /// The custom or automatically generated name after parameter substitution,22    /// if it differs from `command`. Automatic names include environment overrides.23    #[serde(skip_serializing_if = "Option::is_none")]24    pub name: Option<String>,2526    /// The name, followed by parameters not used in the command or environment27    /// templates, in command-line order. For example, `sleep {duration}`28    /// with `duration=1`, `branch=main`, and the custom name `wait {duration}s`29    /// produces `wait 1s (branch = main)`. Without the custom name, this is30    /// `sleep 1 (branch = main)`. Used in summaries and table exports.31    #[serde(skip_serializing)]32    pub display_name: String,3334    /// Performance metric measurements and exit codes for each run35    #[serde(flatten)]36    pub measurements: Measurements,3738    /// Parameter values for this benchmark39    #[serde(skip_serializing_if = "BTreeMap::is_empty")]40    pub parameters: BTreeMap<String, Parameter>,4142    /// Explicit environment overrides after parameter substitution.43    #[serde(skip_serializing_if = "BTreeMap::is_empty")]44    pub environment: BTreeMap<String, String>,45}4647impl BenchmarkResult {48    pub fn get_name(&self) -> &str {49        self.name.as_deref().unwrap_or(&self.command)50    }51}