Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
280c252
Introduce new BenchmarkRun struct
sharkdp Dec 29, 2024
5c3ed07
Move user and system time
sharkdp Dec 29, 2024
daa22d7
Use wait4 instead of getrusage
sharkdp Dec 29, 2024
59581bd
Remove command_with_unused_parameters field
sharkdp Dec 29, 2024
225151c
Real => wall clock
sharkdp Dec 29, 2024
4fdb8da
Simplify run creation
sharkdp Dec 29, 2024
5327ee1
More simplifications
sharkdp Dec 29, 2024
f3b5c00
Runs => Measurements
sharkdp Dec 29, 2024
3f72356
Units
sharkdp Dec 29, 2024
41ffde4
Switch to unit-safe quantities
sharkdp Dec 30, 2024
9645a2b
Unify TimingResult/TimerResult/Measurement
sharkdp Jan 1, 2025
97ceceb
Rename to exit_code
sharkdp Jan 1, 2025
130928c
Add unit information
sharkdp Jan 1, 2025
8093c7e
Add short unit
sharkdp Jan 4, 2025
86d6236
Use uom
sharkdp Jan 4, 2025
1815e78
Use unit system in unix_timer
sharkdp Jan 4, 2025
0036516
Fix Windows timer
sharkdp Jan 4, 2025
d385bf7
Move quantity module
sharkdp Jan 4, 2025
8655c5a
Refactoring
sharkdp Jan 5, 2025
69857b9
Implement TimeUnit functions via uom
sharkdp Jan 5, 2025
ad5f1c8
Support minutes and hours
sharkdp Jan 5, 2025
9efce69
Remove alternative constructors
sharkdp Jan 5, 2025
0cadd2e
TODO comments
sharkdp Jan 5, 2025
d3f9eb5
Fix Windows includes
sharkdp Jan 5, 2025
1b02da9
Quantity API cleanup
sharkdp Jan 11, 2025
b330fa7
Further simplification of the API
sharkdp Jan 11, 2025
aa17b93
Do not use value_in for CSV export
sharkdp Jan 11, 2025
4c14f8a
Represent memory usage as f64 as well
sharkdp Jan 11, 2025
e05e105
Get rid of value_in
sharkdp Jan 11, 2025
54c7e80
Add test
sharkdp Jan 11, 2025
94d1311
Yet another API iteration
sharkdp Jan 11, 2025
50a4d77
Make memory units available
sharkdp Jan 11, 2025
98cb208
Unit safe statistics functions
sharkdp Jan 11, 2025
25dcf75
Cleanup
sharkdp Jan 12, 2025
086e199
Split out statistics module
sharkdp Jan 12, 2025
15160ba
Remove statistical dependency
sharkdp Jan 12, 2025
84e845c
Minor change
sharkdp Jan 12, 2025
7728adb
Minor cleanup
sharkdp Jan 12, 2025
28063eb
Formatting
sharkdp Sep 3, 2025
c32a0be
Fix Windows build error?
sharkdp Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 25 additions & 253 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ windows_process_extensions_main_thread_handle = []
[dependencies]
colored = "2.1"
indicatif = "=0.17.4"
statistical = "1.0"
csv = "1.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -28,6 +27,11 @@ rand = "0.8"
shell-words = "1.0"
thiserror = "2.0"
anyhow = "1.0"
uom = { version = "0.36.0", default-features = false, features = [
"std",
"si",
"f64",
] }

[target.'cfg(not(windows))'.dependencies]
libc = "0.2"
Expand Down
82 changes: 41 additions & 41 deletions src/benchmark/benchmark_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@ use std::collections::BTreeMap;

use serde::Serialize;

use crate::util::units::Second;
use crate::benchmark::measurement::Measurements;
use crate::quantity::Time;

/// 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.
/// Parameter value and whether it was used in the command line template
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
pub struct Parameter {
pub value: String,
pub is_unused: bool,
}

/// Meta data and performance metrics for a single benchmark
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
pub struct BenchmarkResult {
/// The full command line of the program that is being benchmarked
pub command: String,

/// The full command line of the program that is being benchmarked, possibly including a list of
/// parameters that were not used in the command line template.
#[serde(skip_serializing)]
pub command_with_unused_parameters: String,

/// The average run time
pub mean: Second,

/// The standard deviation of all run times. Not available if only one run has been performed
pub stddev: Option<Second>,

/// The median run time
pub median: Second,

/// Time spent in user mode
pub user: Second,

/// Time spent in kernel mode
pub system: Second,

/// Minimum of all measured times
pub min: Second,

/// Maximum of all measured times
pub max: Second,

/// All run time measurements
#[serde(skip_serializing_if = "Option::is_none")]
pub times: Option<Vec<Second>>,

/// Maximum memory usage of the process, in bytes
#[serde(skip_serializing_if = "Option::is_none")]
pub memory_usage_byte: Option<Vec<u64>>,

/// Exit codes of all command invocations
pub exit_codes: Vec<Option<i32>>,
/// Performance metric measurements and exit codes for each run
#[serde(flatten)]
pub measurements: Measurements,

/// Parameter values for this benchmark
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub parameters: BTreeMap<String, String>,
pub parameters: BTreeMap<String, Parameter>,
}

impl BenchmarkResult {
/// 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
/// parameters that were not used in the command line template.
pub fn command_with_unused_parameters(&self) -> String {
let parameters = self
.parameters
.iter()
.filter(|(_, parameter)| parameter.is_unused)
.fold(String::new(), |output, (name, parameter)| {
output + &format!("{name} = {value}, ", value = parameter.value)
});
let parameters = parameters.trim_end_matches(", ");
let parameters = if parameters.is_empty() {
"".into()
} else {
format!(" ({parameters})")
};

format!("{}{}", self.command, parameters)
}
}
Loading