mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-03 01:21:25 +00:00
Fix Windows timer
This commit is contained in:
1 parent
e2fc547dad
commit
e006105e2f
1 file changed
+8
-6
@@ -30,7 +30,7 @@ use windows_sys::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::quantity::{nanosecond, Information, Time, Zero};
|
use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};
|
||||||
|
|
||||||
#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]
|
#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
@@ -84,7 +84,7 @@ impl CPUTimer {
|
|||||||
Self { job_object }
|
Self { job_object }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop(&self, mut child: Child) -> Result<(ExitStatus, Second, Second, u64)> {
|
pub fn stop(&self, mut child: Child) -> Result<(ExitStatus, Time, Time, Information)> {
|
||||||
let status = child.wait()?;
|
let status = child.wait()?;
|
||||||
|
|
||||||
let mut job_object_info =
|
let mut job_object_info =
|
||||||
@@ -108,15 +108,17 @@ impl CPUTimer {
|
|||||||
// The `TotalUserTime` is "The total amount of user-mode execution time for
|
// The `TotalUserTime` is "The total amount of user-mode execution time for
|
||||||
// all active processes associated with the job, as well as all terminated processes no
|
// all active processes associated with the job, as well as all terminated processes no
|
||||||
// longer associated with the job, in 100-nanosecond ticks."
|
// longer associated with the job, in 100-nanosecond ticks."
|
||||||
let user_time = Time::new::<nanosecond>((job_object_info.TotalUserTime as f64) * 100.0);
|
let user_time = Time::from_nanoseconds((job_object_info.TotalUserTime as f64) * 100.0);
|
||||||
|
|
||||||
// The `TotalKernelTime` is "The total amount of kernel-mode execution time
|
// The `TotalKernelTime` is "The total amount of kernel-mode execution time
|
||||||
// for all active processes associated with the job, as well as all terminated
|
// for all active processes associated with the job, as well as all terminated
|
||||||
// processes no longer associated with the job, in 100-nanosecond ticks."
|
// processes no longer associated with the job, in 100-nanosecond ticks."
|
||||||
let kernel: i64 = job_object_info.TotalKernelTime / HUNDRED_NS_PER_MS;
|
let system_time =
|
||||||
Ok((status, user as f64 * 1e-6, kernel as f64 * 1e-6, 0))
|
Time::from_nanoseconds((job_object_info.TotalKernelTime as f64) * 100.0);
|
||||||
|
|
||||||
|
Ok((status, user_time, system_time, Information::zero()))
|
||||||
} else {
|
} else {
|
||||||
Ok((status, 0.0, 0.0, 0))
|
Ok((status, Time::zero(), Time::zero(), Information::zero()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user