Hi Martin:
It may "work" but does it do so correctly?
Robert Wishlaw
#include <windows.h>
#include <stdio.h>
#include <time.h> // contains needed prototype for _sleep function
// User Global Variables
static LARGE_INTEGER lFreq, lLast, lNow, lElapsed;
static double RElapsed;
static int RetVal;
void main(void) {
RetVal = QueryPerformanceFrequency(&lFreq);
if(RetVal == 0)
{
printf("%s\n","This computer does not have a high-performance timer.");
fflush(stdout);
ExitProcess(0);
}
printf("%s\n", "Pelle's C _sleep ");
QueryPerformanceCounter(&lLast);
_sleep(2);
QueryPerformanceCounter(&lNow);
lElapsed.QuadPart = (lNow.QuadPart - lLast.QuadPart) * 1000/lFreq.QuadPart;//mS
printf("%s% .15G%s\n", "did not last ", (double)lElapsed.QuadPart, " seconds,");
RElapsed = (double)(((lNow.QuadPart - lLast.QuadPart) * (1.0 / lFreq.QuadPart)));
printf("%s% .15G%s\n", "it lasted ", RElapsed, " seconds.");
}