Simplify
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent 7fd4aea · Browse files · 1 file·+7 added−20 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+7 added−20 removed
- other:+7 added−20 removed
Provenance
- Commit
f19223b- Tree
5cc8761- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
7fd4aea
1 file changed+7 added−20 removed
modified:src/benchmark/executor.rs+7 added-20 removed
38 unmodified lines39 shell_spawning_time: Option<TimingResult>,40 }41 42 impl<'a> ShellExecutor<'a> {43- fn subtract_shell_spawning_time(&self, time: Second, shell_spawning_time: Second) -> Second {44- if time < shell_spawning_time {45- 0.046- } else {47- time - shell_spawning_time48- }49- }50-43 pub fn new(shell: &'a Shell, options: &'a Options) -> Self {44 ShellExecutor {45 shell,46 options,21 unmodified lines68 )69 .arg(if cfg!(windows) { "/C" } else { "-c" })70 .arg(command.get_command_line());71 80- let result = execute_and_measure(command_builder)72+ let mut result = execute_and_measure(command_builder)73 .with_context(|| format!("Failed to run command '{}'", command.get_command_line()))?;74 83- let mut time_real = result.time_real;84-85- let mut time_user = result.time_user;86- let mut time_system = result.time_system;87-75 if command_failure_action.unwrap_or(self.options.command_failure_action)76 == CmdFailureAction::RaiseError77 && !result.status.success()78 {8 unmodified lines87 }88 89 // Subtract shell spawning time90 if let Some(spawning_time) = self.shell_spawning_time {104- time_real = self.subtract_shell_spawning_time(time_real, spawning_time.time_real);105- time_user = self.subtract_shell_spawning_time(time_user, spawning_time.time_user);106- time_system = self.subtract_shell_spawning_time(time_system, spawning_time.time_system);91+ result.time_real = (result.time_real - spawning_time.time_real).max(0.0);92+ result.time_user = (result.time_user - spawning_time.time_user).max(0.0);93+ result.time_system = (result.time_system - spawning_time.time_system).max(0.0);94 }95 96 Ok((97 TimingResult {111- time_real,112- time_user,113- time_system,98+ time_real: result.time_real,99+ time_user: result.time_user,100+ time_system: result.time_system,101 },102 result.status,103 ))104 }129 unmodified lines