| View previous topic :: View next topic |
| Author |
Message |
Jim Ablett

Joined: 14 Jul 2006 Posts: 1246 Location: London, England
|
Post subject: Re: CPU time in Windows Posted: Tue Feb 14, 2012 11:34 am |
|
|
This is a better solution to Mingw32 cpu time bug >
| Code: |
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static void
__winnt_cpu_time (long *sec, long *usec)
{
union {
FILETIME ft;
unsigned long long ulltime;
} kernel_time, user_time;
FILETIME unused1, unused2;
unsigned long long total_time;
/* No support for Win9x. The high order bit of the DWORD
returned by GetVersion is 0 for NT and higher. */
if (GetVersion () >= 0x80000000)
{
*sec = -1;
*usec = 0;
return;
}
/* The FILETIME structs filled in by GetProcessTimes represent
time in 100 nanosecond units. */
GetProcessTimes (GetCurrentProcess (), &unused1, &unused2,
&kernel_time.ft, &user_time.ft);
total_time = (kernel_time.ulltime + user_time.ulltime)/10;
*sec = total_time / 1000000;
*usec = total_time % 1000000;
}
|
Jim. _________________ http://jimablett.atwebpages.com/ |
|
| Back to top |
|
 |
|
| Subject |
Author |
Date/Time |
CPU time in Windows |
H.G.Muller |
Mon Feb 13, 2012 6:18 pm |
Re: CPU time in Windows |
Jim Ablett |
Mon Feb 13, 2012 6:50 pm |
Re: CPU time in Windows |
H.G.Muller |
Mon Feb 13, 2012 7:27 pm |
Re: CPU time in Windows |
Jim Ablett |
Tue Feb 14, 2012 1:11 am |
Re: CPU time in Windows |
Jim Ablett |
Tue Feb 14, 2012 11:34 am |
Re: CPU time in Windows |
Daniel Shawul |
Tue Feb 14, 2012 12:41 pm |
Re: CPU time in Windows |
Ricardo Barreira |
Sun Feb 19, 2012 1:07 pm |
Re: CPU time in Windows |
Daniel Shawul |
Sun Feb 19, 2012 5:16 pm |
Re: CPU time in Windows |
H.G.Muller |
Sun Feb 19, 2012 12:17 pm |
Re: CPU time in Windows |
Jim Ablett |
Sun Feb 19, 2012 12:43 pm |
Re: CPU time in Windows |
H.G.Muller |
Sun Feb 19, 2012 1:00 pm |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|