fix windows version of GetRunningMicroSecs()

This commit is contained in:
Dick Hollenbeck 2012-01-13 11:11:34 -06:00
parent 3421863c01
commit 5a9fcf6f11
1 changed files with 22 additions and 11 deletions

View File

@ -40,23 +40,34 @@ unsigned GetRunningMicroSecs()
unsigned GetRunningMicroSecs() unsigned GetRunningMicroSecs()
{ {
LARGE_INTEGER curtime; FILETIME now;
static unsigned timerFreq; // timer frequency GetSystemTimeAsFileTime( &now );
if( !timerFreq ) typedef unsigned long long UINT64;
{
QueryPerformanceFrequency( &curtime );
timerFreq = curtime.QuadPart / 1000000; // i.e., ticks per usec UINT64 t = (UINT64(now.dwHighDateTime) << 32) + now.dwLowDateTime;
assert( timerFreq ); t /= 10;
}
QueryPerformanceCounter( &curtime ); return unsigned( t );
return ( curtime.LowPart / timerFreq );
} }
#if 0
// test program
#include <stdio.h>
int main( int argc, char** argv )
{
unsigned then = GetRunningMicroSecs();
Sleep( 2000 ); // Windows Sleep( msecs )
printf( "delta: %u\n", GetRunningMicroSecs() - then );
return 0;
}
#endif
#endif #endif