Skip to content

Commit d869e8a

Browse files
committed
Fix Windows timer
1 parent 6c5eae3 commit d869e8a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/timer/windows_timer.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ use windows_sys::{
3030
},
3131
};
3232

33-
use crate::util::units::Second;
34-
35-
const HUNDRED_NS_PER_MS: i64 = 10;
33+
use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};
3634

3735
#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]
3836
#[allow(non_upper_case_globals)]
@@ -89,7 +87,7 @@ impl CPUTimer {
8987
Self { job_object }
9088
}
9189

92-
pub fn stop(&self, mut child: Child) -> Result<(ExitStatus, Second, Second, u64)> {
90+
pub fn stop(&self, mut child: Child) -> Result<(ExitStatus, Time, Time, Information)> {
9391
let status = child.wait()?;
9492

9593
let mut job_object_info =
@@ -113,15 +111,17 @@ impl CPUTimer {
113111
// The `TotalUserTime` is "The total amount of user-mode execution time for
114112
// all active processes associated with the job, as well as all terminated processes no
115113
// longer associated with the job, in 100-nanosecond ticks."
116-
let user: i64 = job_object_info.TotalUserTime / HUNDRED_NS_PER_MS;
114+
let user_time = Time::from_nanoseconds((job_object_info.TotalUserTime as f64) * 100.0);
117115

118116
// The `TotalKernelTime` is "The total amount of kernel-mode execution time
119117
// for all active processes associated with the job, as well as all terminated
120118
// processes no longer associated with the job, in 100-nanosecond ticks."
121-
let kernel: i64 = job_object_info.TotalKernelTime / HUNDRED_NS_PER_MS;
122-
Ok((status, user as f64 * 1e-6, kernel as f64 * 1e-6, 0))
119+
let system_time =
120+
Time::from_nanoseconds((job_object_info.TotalKernelTime as f64) * 100.0);
121+
122+
Ok((status, user_time, system_time, Information::zero()))
123123
} else {
124-
Ok((status, 0.0, 0.0, 0))
124+
Ok((status, Time::zero(), Time::zero(), Information::zero()))
125125
}
126126
}
127127
}

0 commit comments

Comments
 (0)