From 95e462e7503c59df17330eb254ec3bff535fb2ab Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 18 Oct 2011 00:42:05 +0000 Subject: [PATCH] windows version of CPU time measurement --- src/session_impl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0e0c2b2a2..9aee67072 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -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 }