Compare commits

..
Author SHA1 Message Date
David Peter 35c94a0e36 Clarify internal measurement field names 2026-10-05 10:09:41 +02:00
David Peter 750fe11b85 Merge pull request #954 from sharkdp/codex/remove-statistical
Replace statistical with local floating-point helpers
2026-10-05 10:03:27 +02:00
David Peter 258af076cb Merge pull request #854 from Rohan5commit/docs/fix-arithmetic-wording
docs: fix arithmetic wording in help text
2026-10-05 09:46:30 +02:00
David Peter fe75d1cb1b Merge pull request #853 from Rohan5commit/docs/fix-comment-typo
docs: fix typo in relative speed comment
2026-10-05 09:46:07 +02:00
rohan436 926b89c770 docs: fix arithmetic wording in help text 2026-03-13 13:35:56 +08:00
rohan436 7720bfaba8 docs: fix typo in relative speed comment 2026-03-13 13:29:46 +08:00
6 changed files with 41 additions and 38 deletions

No files matched your search

+15 -14
View File
@@ -79,7 +79,7 @@ fn run_command_and_measure_common(
let result = execute_and_measure(command) let result = execute_and_measure(command)
.with_context(|| format!("Failed to run command '{command_name}'"))?; .with_context(|| format!("Failed to run command '{command_name}'"))?;
if !result.status.success() { if !result.exit_status.success() {
use crate::util::exit_code::extract_exit_code; use crate::util::exit_code::extract_exit_code;
let should_fail = match command_failure_action { let should_fail = match command_failure_action {
@@ -87,7 +87,7 @@ fn run_command_and_measure_common(
CmdFailureAction::IgnoreAllFailures => false, CmdFailureAction::IgnoreAllFailures => false,
CmdFailureAction::IgnoreSpecificFailures(ref codes) => { CmdFailureAction::IgnoreSpecificFailures(ref codes) => {
// Only fail if the exit code is not in the list of codes to ignore // Only fail if the exit code is not in the list of codes to ignore
if let Some(exit_code) = extract_exit_code(result.status) { if let Some(exit_code) = extract_exit_code(result.exit_status) {
!codes.contains(&exit_code) !codes.contains(&exit_code)
} else { } else {
// If we can't extract an exit code, treat it as a failure // If we can't extract an exit code, treat it as a failure
@@ -107,7 +107,7 @@ fn run_command_and_measure_common(
bail!( bail!(
"{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \ "{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \
Alternatively, use the '--show-output' option to debug what went wrong.", Alternatively, use the '--show-output' option to debug what went wrong.",
cause=result.status.code().map_or( cause=result.exit_status.code().map_or(
"The process has been terminated by a signal".into(), "The process has been terminated by a signal".into(),
|c| format!("Command terminated with non-zero exit code {c}") |c| format!("Command terminated with non-zero exit code {c}")
@@ -203,7 +203,8 @@ impl Executor for ShellExecutor<'_> {
// Subtract shell spawning time // Subtract shell spawning time
if let Some(spawning_time) = self.shell_spawning_time { if let Some(spawning_time) = self.shell_spawning_time {
result.time_real = (result.time_real - spawning_time.time_real).max(0.0); result.time_wall_clock =
(result.time_wall_clock - spawning_time.time_wall_clock).max(0.0);
result.time_user = (result.time_user - spawning_time.time_user).max(0.0); result.time_user = (result.time_user - spawning_time.time_user).max(0.0);
result.time_system = (result.time_system - spawning_time.time_system).max(0.0); result.time_system = (result.time_system - spawning_time.time_system).max(0.0);
} }
@@ -251,7 +252,7 @@ impl Executor for ShellExecutor<'_> {
); );
} }
Ok(r) => { Ok(r) => {
times_real.push(r.time_real); times_real.push(r.time_wall_clock);
times_user.push(r.time_user); times_user.push(r.time_user);
times_system.push(r.time_system); times_system.push(r.time_system);
} }
@@ -267,18 +268,18 @@ impl Executor for ShellExecutor<'_> {
} }
self.shell_spawning_time = Some(Measurement { self.shell_spawning_time = Some(Measurement {
time_real: mean(&times_real), time_wall_clock: mean(&times_real),
time_user: mean(&times_user), time_user: mean(&times_user),
time_system: mean(&times_system), time_system: mean(&times_system),
memory_usage_byte: 0, peak_memory_usage: 0,
status: ExitStatus::default(), exit_status: ExitStatus::default(),
}); });
Ok(()) Ok(())
} }
fn time_overhead(&self) -> Second { fn time_overhead(&self) -> Second {
self.shell_spawning_time.unwrap().time_real self.shell_spawning_time.unwrap().time_wall_clock
} }
} }
@@ -311,23 +312,23 @@ impl Executor for MockExecutor {
_output_policy: &CommandOutputPolicy, _output_policy: &CommandOutputPolicy,
) -> Result<Measurement> { ) -> Result<Measurement> {
#[cfg(unix)] #[cfg(unix)]
let status = { let exit_status = {
use std::os::unix::process::ExitStatusExt; use std::os::unix::process::ExitStatusExt;
ExitStatus::from_raw(0) ExitStatus::from_raw(0)
}; };
#[cfg(windows)] #[cfg(windows)]
let status = { let exit_status = {
use std::os::windows::process::ExitStatusExt; use std::os::windows::process::ExitStatusExt;
ExitStatus::from_raw(0) ExitStatus::from_raw(0)
}; };
Ok(Measurement { Ok(Measurement {
time_real: Self::extract_time(command.get_command_line()), time_wall_clock: Self::extract_time(command.get_command_line()),
time_user: 0.0, time_user: 0.0,
time_system: 0.0, time_system: 0.0,
memory_usage_byte: 0, peak_memory_usage: 0,
status, exit_status,
}) })
} }
+3 -3
View File
@@ -6,7 +6,7 @@ use crate::util::units::Second;
#[derive(Debug, Default, Copy, Clone)] #[derive(Debug, Default, Copy, Clone)]
pub struct Measurement { pub struct Measurement {
/// Wall clock time /// Wall clock time
pub time_real: Second, pub time_wall_clock: Second,
/// Time spent in user mode /// Time spent in user mode
pub time_user: Second, pub time_user: Second,
@@ -15,8 +15,8 @@ pub struct Measurement {
pub time_system: Second, pub time_system: Second,
/// Maximum amount of memory used, in bytes /// Maximum amount of memory used, in bytes
pub memory_usage_byte: u64, pub peak_memory_usage: u64,
/// The exit status of the process /// The exit status of the process
pub status: ExitStatus, pub exit_status: ExitStatus,
} }
+15 -13
View File
@@ -241,8 +241,9 @@ impl<'a> Benchmark<'a> {
}; };
let preparation_result = run_preparation_command()?; let preparation_result = run_preparation_command()?;
let preparation_overhead = let preparation_overhead = preparation_result.map_or(0.0, |res| {
preparation_result.map_or(0.0, |res| res.time_real + self.executor.time_overhead()); res.time_wall_clock + self.executor.time_overhead()
});
// Initial timing run // Initial timing run
let res = self.executor.run_command_and_measure( let res = self.executor.run_command_and_measure(
@@ -251,15 +252,16 @@ impl<'a> Benchmark<'a> {
None, None,
output_policy, output_policy,
)?; )?;
let success = res.status.success(); let success = res.exit_status.success();
let conclusion_result = run_conclusion_command()?; let conclusion_result = run_conclusion_command()?;
let conclusion_overhead = let conclusion_overhead = conclusion_result.map_or(0.0, |res| {
conclusion_result.map_or(0.0, |res| res.time_real + self.executor.time_overhead()); res.time_wall_clock + self.executor.time_overhead()
});
// Determine number of benchmark runs // Determine number of benchmark runs
let runs_in_min_time = (self.options.min_benchmarking_time let runs_in_min_time = (self.options.min_benchmarking_time
/ (res.time_real / (res.time_wall_clock
+ self.executor.time_overhead() + self.executor.time_overhead()
+ preparation_overhead + preparation_overhead
+ conclusion_overhead)) as u64; + conclusion_overhead)) as u64;
@@ -278,11 +280,11 @@ impl<'a> Benchmark<'a> {
let count_remaining = count - 1; let count_remaining = count - 1;
// Save the first result // Save the first result
times_real.push(res.time_real); times_real.push(res.time_wall_clock);
times_user.push(res.time_user); times_user.push(res.time_user);
times_system.push(res.time_system); times_system.push(res.time_system);
memory_usage_byte.push(res.memory_usage_byte); memory_usage_byte.push(res.peak_memory_usage);
exit_codes.push(extract_exit_code(res.status)); exit_codes.push(extract_exit_code(res.exit_status));
all_succeeded = all_succeeded && success; all_succeeded = all_succeeded && success;
@@ -313,13 +315,13 @@ impl<'a> Benchmark<'a> {
None, None,
output_policy, output_policy,
)?; )?;
let success = res.status.success(); let success = res.exit_status.success();
times_real.push(res.time_real); times_real.push(res.time_wall_clock);
times_user.push(res.time_user); times_user.push(res.time_user);
times_system.push(res.time_system); times_system.push(res.time_system);
memory_usage_byte.push(res.memory_usage_byte); memory_usage_byte.push(res.peak_memory_usage);
exit_codes.push(extract_exit_code(res.status)); exit_codes.push(extract_exit_code(res.exit_status));
all_succeeded = all_succeeded && success; all_succeeded = all_succeeded && success;
+1 -1
View File
@@ -52,7 +52,7 @@ fn compute_relative_speeds<'a>(
}; };
// https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Example_formulas // https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Example_formulas
// Covariance asssumed to be 0, i.e. variables are assumed to be independent // Covariance assumed to be 0, i.e. variables are assumed to be independent
let ratio_stddev = match (result.stddev, reference.stddev) { let ratio_stddev = match (result.stddev, reference.stddev) {
(Some(result_stddev), Some(fastest_stddev)) => Some( (Some(result_stddev), Some(fastest_stddev)) => Some(
ratio ratio
+1 -1
View File
@@ -167,7 +167,7 @@ fn build_command() -> Command {
string '{VAR}' in each command by the current parameter value.\n\n \ string '{VAR}' in each command by the current parameter value.\n\n \
Example: hyperfine --prepare 'make clean' -P threads 1 8 'make -j {threads}'\n\n\ Example: hyperfine --prepare 'make clean' -P threads 1 8 'make -j {threads}'\n\n\
This performs benchmarks for 'make -j 1', 'make -j 2', …, 'make -j 8'.\n\n\ This performs benchmarks for 'make -j 1', 'make -j 2', …, 'make -j 8'.\n\n\
To have the value increase following different patterns, use shell arithmetics.\n\n \ To have the value increase following different patterns, use shell arithmetic.\n\n \
Example: hyperfine -P size 0 3 'sleep $((2**{size}))'\n\n\ Example: hyperfine -P size 0 3 'sleep $((2**{size}))'\n\n\
This performs benchmarks with power of 2 increases: 'sleep 1', 'sleep 2', 'sleep 4', …\n\ This performs benchmarks with power of 2 increases: 'sleep 1', 'sleep 2', 'sleep 4', …\n\
The exact syntax may vary depending on your shell and OS." The exact syntax may vary depending on your shell and OS."
+6 -6
View File
@@ -95,16 +95,16 @@ pub fn execute_and_measure(mut command: Command) -> Result<Measurement> {
discard(output); discard(output);
} }
let status = child.wait()?; let exit_status = child.wait()?;
let time_real = wallclock_timer.stop(); let time_wall_clock = wallclock_timer.stop();
let (time_user, time_system, memory_usage_byte) = cpu_timer.stop(); let (time_user, time_system, peak_memory_usage) = cpu_timer.stop();
Ok(Measurement { Ok(Measurement {
time_real, time_wall_clock,
time_user, time_user,
time_system, time_system,
memory_usage_byte, peak_memory_usage,
status, exit_status,
}) })
} }