18 #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
22 LARGE_INTEGER time, freq;
23 double dtime, dfreq, res;
24 if (QueryPerformanceCounter(&time) == 0)
26 DWORD err = GetLastError();
29 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
32 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
36 printf(
"QueryPerformanceCounter() failed with error %d: %s\n", err, buf);
40 if (QueryPerformanceFrequency(&freq) == 0)
42 DWORD err = GetLastError();
45 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
48 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
52 printf(
"QueryPerformanceFrequency() failed with error %d: %s\n", err, buf);
56 dtime = Li2Double(time);
57 dfreq = Li2Double(freq);
68 gettimeofday(&tv, (
struct timezone*)0);
69 return ((
double)tv.tv_sec + (
double)tv.tv_usec / 1000000.0 );