windows version of CPU time measurement

This commit is contained in:
Arvid Norberg 2011-10-18 00:42:05 +00:00
parent 7d20c0b0c4
commit 95e462e750
1 changed files with 13 additions and 1 deletions

View File

@ -3228,7 +3228,19 @@ namespace aux {
+ seconds(ru.ru_stime.tv_sec)
+ microsec(ru.ru_stime.tv_usec);
#elif defined TORRENT_WINDOWS
// GetThreadTimes
FILETIME system_time;
FILETIME user_time;
FILETIME creation_time;
FILETIME exit_time;
GetThreadTimes(GetCurrentThread(), &creation_time, &exit_time, &user_time, &system_time);
boost::uint64_t utime = (boost::uint64_t(user_time.dwhighdatetime) << 32)
+ user_time.dwlowdatetime;
boost::uint64_t stime = (boost::uint64_t(system_time.dwhighdatetime) << 32)
+ system_time.dwlowdatetime;
tu->user_time = min_time() + microsec(utime / 10);
tu->system_time = min_time() + microsec(stime / 10);
#endif
}