Refine JSON schema and command metadata

This commit is contained in:
David Peter committed 2026-10-05 18:11:10 +02:00
1 parent c5d3a81fc5
commit 0d86e78ede
15 files changed
+59 -60

No files matched your search

+10 -5
View File
@@ -9,18 +9,19 @@ use crate::quantity::Time;
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
pub struct Parameter {
pub value: String,
#[serde(skip_serializing)]
pub is_unused: bool,
}
/// Meta data and performance metrics for a single benchmark
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
pub struct BenchmarkResult {
/// The display name of the command being benchmarked
/// The expanded command line being benchmarked
pub command: String,
/// The expanded command line, when it differs from the display name
/// The display name, when it differs from the command line
#[serde(skip_serializing_if = "Option::is_none")]
pub command_raw: Option<String>,
pub name: Option<String>,
/// Performance metric measurements and exit codes for each run
#[serde(flatten)]
@@ -32,12 +33,16 @@ pub struct BenchmarkResult {
}
impl BenchmarkResult {
pub fn get_name(&self) -> &str {
self.name.as_deref().unwrap_or(&self.command)
}
/// The average wall clock time
pub fn mean_wall_clock_time(&self) -> Time {
self.measurements.time_wall_clock_mean()
}
/// The full command line of the program that is being benchmarked, possibly including a list of
/// The display name of the command, possibly including a list of
/// parameters that were not used in the command line template.
pub fn command_with_unused_parameters(&self) -> String {
let parameters = self
@@ -54,6 +59,6 @@ impl BenchmarkResult {
format!(" ({parameters})")
};
format!("{}{}", self.command, parameters)
format!("{}{}", self.get_name(), parameters)
}
}
+4 -4
View File
@@ -475,13 +475,13 @@ impl<'a> Benchmark<'a> {
self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?;
let command = self.command.get_name();
let command_raw = self.command.get_command_line();
let command_raw = (command_raw != command).then_some(command_raw);
let command = self.command.get_command_line();
let name = self.command.get_name();
let name = (name != command).then_some(name);
Ok(BenchmarkResult {
command,
command_raw,
name,
measurements,
parameters: self
.command
+1 -1
View File
@@ -158,7 +158,7 @@ fn create_result(name: &str, mean: f64) -> BenchmarkResult {
BenchmarkResult {
command: name.into(),
command_raw: None,
name: None,
measurements: Measurements {
measurements: vec![Measurement {
time_wall_clock: Time::new::<second>(mean),