Skip to content
Myr

Add dummy timer for Windows

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by David Peter · parent fefb3f2 · Browse files · 1 file+11 added−2 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+11 added−2 removed

  • other:+11 added−2 removed

1 file+11 added−2 removed

modified:src/hyperfine/timer/cputimer.rs+11 added-2 removed
1use std::mem;21use hyperfine::internal::Second;2use hyperfine::timer::Timer;34#[derive(Debug, Copy, Clone)]
14 unmodified lines
19 pub system: Second,20}2122/// Read CPU execution times ('user' and 'system')23#[cfg(not(target_os = "windows"))]24fn get_cpu_times() -> CPUTimes {25 use libc::{getrusage, rusage, RUSAGE_CHILDREN};26 use std::mem;2728 let result: rusage = unsafe {29 let mut buf = mem::zeroed();30 let success = getrusage(RUSAGE_CHILDREN, &mut buf);
10 unmodified lines
41 + i64::from(result.ru_stime.tv_usec),42 }43}4445/// Read CPU execution times (dummy for now)46#[cfg(windows)]47fn get_cpu_times() -> CPUTimes {48 CPUTimes {49 user_usec: 0,50 system_usec: 0,51 }52}5354/// Compute the time intervals in between two `CPUTimes` snapshots55fn cpu_time_interval(start: &CPUTimes, end: &CPUTimes) -> CPUInterval {56 CPUInterval {57 user: ((end.user_usec - start.user_usec) as f64) * 1e-6,
49 unmodified lines