mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Document JSON measurements and omit unavailable memory metrics
This commit is contained in:
1 parent
21bbcc5490
commit
4cd0e24586
9 files changed
+147
-44
No files matched your search
@@ -277,7 +277,7 @@ impl Executor for ShellExecutor<'_> {
|
||||
time_wall_clock: measurements.time_wall_clock_mean(),
|
||||
time_user: measurements.time_user_mean(),
|
||||
time_system: measurements.time_system_mean(),
|
||||
peak_memory_usage: measurements.peak_memory_usage_mean(),
|
||||
peak_memory_usage: None,
|
||||
exit_status: ExitStatus::default(),
|
||||
});
|
||||
|
||||
@@ -335,7 +335,7 @@ impl Executor for MockExecutor {
|
||||
time_wall_clock: Self::extract_time(command.get_command_line()),
|
||||
time_user: Time::zero(),
|
||||
time_system: Time::zero(),
|
||||
peak_memory_usage: Information::zero(),
|
||||
peak_memory_usage: Some(Information::zero()),
|
||||
exit_status,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,6 +16,19 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn serialize_optional_information<S>(
|
||||
value: &Option<Information>,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
match value {
|
||||
Some(value) => serialize_information(value, serializer),
|
||||
None => serializer.serialize_none(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Performance metric measurements and exit code for a single run
|
||||
#[derive(Debug, Clone, Default, Serialize, PartialEq)]
|
||||
pub struct Measurement {
|
||||
@@ -31,9 +44,12 @@ pub struct Measurement {
|
||||
#[serde(serialize_with = "serialize_time")]
|
||||
pub time_system: Time,
|
||||
|
||||
/// Maximum memory usage of the process
|
||||
#[serde(serialize_with = "serialize_information")]
|
||||
pub peak_memory_usage: Information,
|
||||
/// Peak resident set size, if available on this platform
|
||||
#[serde(
|
||||
skip_serializing_if = "Option::is_none",
|
||||
serialize_with = "serialize_optional_information"
|
||||
)]
|
||||
pub peak_memory_usage: Option<Information>,
|
||||
|
||||
// The exit status of the process
|
||||
#[serde(rename = "exit_code", serialize_with = "serialize_exit_status")]
|
||||
@@ -111,8 +127,4 @@ impl Measurements {
|
||||
pub fn time_system_mean(&self) -> Time {
|
||||
mean(self.measurements.iter().map(|m| m.time_system))
|
||||
}
|
||||
|
||||
pub fn peak_memory_usage_mean(&self) -> Information {
|
||||
mean(self.measurements.iter().map(|m| m.peak_memory_usage))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user