mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 17:00:18 +00:00
Store parameter usage metadata in benchmark results
This commit is contained in:
1 parent
29a0ef164d
commit
8c40de45f8
3 files changed
+50
-8
No files matched your search
@@ -2,6 +2,15 @@ use std::collections::BTreeMap;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
/// Parameter value and whether it was used in the command line template
|
||||
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
|
||||
#[serde(transparent)]
|
||||
pub struct Parameter {
|
||||
pub value: String,
|
||||
#[serde(skip)]
|
||||
pub is_unused: bool,
|
||||
}
|
||||
|
||||
/// Set of values that will be exported.
|
||||
// NOTE: `serde` is used for JSON serialization, but not for CSV serialization due to the
|
||||
// `parameters` map. Update `src/hyperfine/export/csv.rs` with new fields, as appropriate.
|
||||
@@ -49,5 +58,5 @@ pub struct BenchmarkResult {
|
||||
|
||||
/// Parameter values for this benchmark
|
||||
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub parameters: BTreeMap<String, String>,
|
||||
pub parameters: BTreeMap<String, Parameter>,
|
||||
}
|
||||
+10
-2
@@ -19,7 +19,7 @@ use crate::output::warnings::{OutlierWarningOptions, Warnings};
|
||||
use crate::parameter::ParameterNameAndValue;
|
||||
use crate::quantity::{byte, const_time_from_seconds, ratio, second, FormatQuantity, Time, Zero};
|
||||
use crate::util::exit_code::extract_exit_code;
|
||||
use benchmark_result::BenchmarkResult;
|
||||
use benchmark_result::{BenchmarkResult, Parameter};
|
||||
use measurement::{Measurement, Measurements};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
@@ -474,7 +474,15 @@ impl<'a> Benchmark<'a> {
|
||||
.command
|
||||
.get_parameters()
|
||||
.iter()
|
||||
.map(|(name, value)| (name.to_string(), value.to_string()))
|
||||
.map(|(name, value)| {
|
||||
(
|
||||
name.to_string(),
|
||||
Parameter {
|
||||
value: value.to_string(),
|
||||
is_unused: self.command.is_parameter_unused(name),
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user