@@ -30,9 +30,7 @@ use windows_sys::{
30
30
} ,
31
31
} ;
32
32
33
- use crate :: util:: units:: Second ;
34
-
35
- const HUNDRED_NS_PER_MS : i64 = 10 ;
33
+ use crate :: benchmark:: quantity:: { Information , InformationQuantity , Time , TimeQuantity } ;
36
34
37
35
#[ cfg( not( feature = "windows_process_extensions_main_thread_handle" ) ) ]
38
36
#[ allow( non_upper_case_globals) ]
@@ -89,7 +87,7 @@ impl CPUTimer {
89
87
Self { job_object }
90
88
}
91
89
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 ) > {
93
91
let status = child. wait ( ) ?;
94
92
95
93
let mut job_object_info =
@@ -113,15 +111,17 @@ impl CPUTimer {
113
111
// The `TotalUserTime` is "The total amount of user-mode execution time for
114
112
// all active processes associated with the job, as well as all terminated processes no
115
113
// 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 ) ;
117
115
118
116
// The `TotalKernelTime` is "The total amount of kernel-mode execution time
119
117
// for all active processes associated with the job, as well as all terminated
120
118
// 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 ( ) ) )
123
123
} else {
124
- Ok ( ( status, 0.0 , 0.0 , 0 ) )
124
+ Ok ( ( status, Time :: zero ( ) , Time :: zero ( ) , Information :: zero ( ) ) )
125
125
}
126
126
}
127
127
}
0 commit comments