mod.rs
This file
Path
src/timer/mod.rs
64 lines · 1.5 KiB · Rust
Last changed by
Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
History of this fileTake it
Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
line 1why, one step back1mod wall_clock_timer;Remove timer/internal.rsDavid Peterbefore adoption9d61130
line 2why, one step back2Remove cfg-if dependencyDavid Peterbefore adoption60e9771
line 3why, one step back3#[cfg(windows)]Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 4why, one step back4mod windows_timer;Flat directory/module structureDavid Peterbefore adoption30c381f
line 5why, one step back5Remove cfg-if dependencyDavid Peterbefore adoption60e9771
line 6why, one step back6#[cfg(not(windows))]Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 7why, one step back7mod unix_timer;Remove timer/internal.rsDavid Peterbefore adoption9d61130
line 8why, one step back8Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 9why, one step back9use crate::util::units::Second;Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
line 10why, one step back10use wall_clock_timer::WallClockTimer;Move to timer moduleDavid Peterbefore adoption0ffc6d7
lines 11–13why, one step back1112use std::process::{Command, ExitStatus};13Further simplify execute_and_measureDavid Peterbefore adoptione1da8ba
line 14why, one step back14use anyhow::Result;Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 15why, one step back15Remove timer/internal.rsDavid Peterbefore adoption9d61130
line 16why, one step back16#[derive(Debug, Copy, Clone)]Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 17why, one step back17struct CPUTimes {Remove timer/internal.rsDavid Peterbefore adoption9d61130
lines 18–24why, one step back18 /// Total amount of time spent executing in user mode19 pub user_usec: i64,2021 /// Total amount of time spent executing in kernel mode22 pub system_usec: i64,23}24Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 25why, one step back25/// Used to indicate the result of running a commandRemove timer/internal.rsDavid Peterbefore adoption9d61130
line 26why, one step back26#[derive(Debug, Copy, Clone)]Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 27why, one step back27pub struct ExecuteResult {Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
lines 28–30why, one step back28 pub time_real: Second,29 pub time_user: Second,30 pub time_system: Second,Remove timer/internal.rsDavid Peterbefore adoption9d61130
line 31why, one step back31Move to timer moduleDavid Peterbefore adoption0ffc6d7
lines 32–36why, one step back32 /// The exit status of the process33 pub status: ExitStatus,34}3536/// Execute the given command and return a timing summaryFurther simplify execute_and_measureDavid Peterbefore adoptione1da8ba
line 37why, one step back37pub fn execute_and_measure(mut command: Command) -> Result<ExecuteResult> {Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
line 38why, one step back38 let wallclock_timer = WallClockTimer::start();Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 39why, one step back39Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
lines 40–45why, one step back40 #[cfg(not(windows))]41 let ((time_user, time_system), status) = {42 let cpu_timer = self::unix_timer::CPUTimer::start();43 let status = command.status()?;44 (cpu_timer.stop(), status)45 };Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 46why, one step back46Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
lines 47–51why, one step back47 #[cfg(windows)]48 let ((time_user, time_system), status) = {49 let mut child = command.spawn()?;50 let cpu_timer = self::windows_timer::CPUTimer::start_for_process(&child);51 let status = child.wait()?;Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 52why, one step back52Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
lines 53–57why, one step back53 (cpu_timer.stop(), status)54 };5556 let time_real = wallclock_timer.stop();57Move to timer moduleDavid Peterbefore adoption0ffc6d7
line 58why, one step back58 Ok(ExecuteResult {Move wall clock timer into execute_and_measureDavid Peterbefore adoption55f0ef6
lines 59–61why, one step back59 time_real,60 time_user,61 time_system,Move to timer moduleDavid Peterbefore adoption0ffc6d7
lines 62–63why, one step back62 status,63 })Flat directory/module structureDavid Peterbefore adoption30c381f
line 64why, one step back64}