Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double GetSeconds();
- {
- LARGE_INTEGER t;
- FILETIME f;
- double microseconds;
- static LARGE_INTEGER offset;
- static double FrequencyToMicroseconds;
- static int initialized = 0;
- static BOOL UsePerformanceCounter = 0;
- if ( !initialized )
- {
- LARGE_INTEGER performanceFrequency;
- initialized = 1;
- UsePerformanceCounter = QueryPerformanceFrequency( &performanceFrequency );
- if ( UsePerformanceCounter )
- {
- QueryPerformanceCounter( &offset );
- FrequencyToMicroseconds = ( double )performanceFrequency.QuadPart / 1000000.;
- }
- else
- {
- offset = getFILETIMEoffset();
- FrequencyToMicroseconds = 10.;
- }
- }
- if ( UsePerformanceCounter )
- QueryPerformanceCounter( &t );
- else
- {
- GetSystemTimeAsFileTime( &f );
- t.QuadPart = f.dwHighDateTime;
- t.QuadPart <<= 32;
- t.QuadPart |= f.dwLowDateTime;
- }
- t.QuadPart -= offset.QuadPart;
- microseconds = ( double )t.QuadPart / FrequencyToMicroseconds;
- t.QuadPart = microseconds;
- tv->tv_sec = t.QuadPart / 1000000;
- tv->tv_usec = t.QuadPart % 1000000;
- return (double)(tv->tv_nsec / CLOCKS_PER_SEC) / 1000.0 + (double)tv->tv_sec;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement