Skip to content
Myr

Fix Windows timer

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 e2fc547 · Browse files · 1 file+8 added−6 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+8 added−6 removed

  • other:+8 added−6 removed

1 file+8 added−6 removed

modified:src/timer/windows_timer.rs+8 added-6 removed
28 unmodified lines
29 System::LibraryLoader::{GetModuleHandleW, GetProcAddress},30 },31};3233use crate::quantity::{nanosecond, Information, Time, Zero};33use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};3435#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]36#[allow(non_upper_case_globals)]37static NtResumeProcess: Lazy<unsafe extern "system" fn(process_handle: HANDLE) -> NTSTATUS> =
45 unmodified lines
8384 Self { job_object }85 }8687 pub fn stop(&self, mut child: Child) -> Result<(ExitStatus, Second, Second, u64)> {87 pub fn stop(&self, mut child: Child) -> Result<(ExitStatus, Time, Time, Information)> {88 let status = child.wait()?;8990 let mut job_object_info =91 mem::MaybeUninit::<JOBOBJECT_BASIC_ACCOUNTING_INFORMATION>::uninit();
15 unmodified lines
107108 // The `TotalUserTime` is "The total amount of user-mode execution time for109 // all active processes associated with the job, as well as all terminated processes no110 // longer associated with the job, in 100-nanosecond ticks."111 let user_time = Time::new::<nanosecond>((job_object_info.TotalUserTime as f64) * 100.0);111 let user_time = Time::from_nanoseconds((job_object_info.TotalUserTime as f64) * 100.0);112113 // The `TotalKernelTime` is "The total amount of kernel-mode execution time114 // for all active processes associated with the job, as well as all terminated115 // processes no longer associated with the job, in 100-nanosecond ticks."116 let kernel: i64 = job_object_info.TotalKernelTime / HUNDRED_NS_PER_MS;117 Ok((status, user as f64 * 1e-6, kernel as f64 * 1e-6, 0))116 let system_time =117 Time::from_nanoseconds((job_object_info.TotalKernelTime as f64) * 100.0);118119 Ok((status, user_time, system_time, Information::zero()))120 } else {119 Ok((status, 0.0, 0.0, 0))121 Ok((status, Time::zero(), Time::zero(), Information::zero()))122 }123 }124}125
6 unmodified lines