I've coded a stopwatch with a very hi resolution.
It uses WIN32 functions 'QueryPerformanceFrequency' and 'QueryPerformanceCounter'. I made a little console test program with an animated prompt, to show how to apply the stopwatch object.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <conio.h>
class StopWatch
{
private:
LARGE_INTEGER liFreq;
LARGE_INTEGER liStart;
LARGE_INTEGER liStop;
public:
BOOL bAvailable;
public:
StopWatch()
{
liStart.QuadPart = liStop.QuadPart = 0;
bAvailable = QueryPerformanceFrequency(&liFreq);
}
void Start()
{
QueryPerformanceCounter(&liStart);
}
double Stop()
{
QueryPerformanceCounter(&liStop);
return (((double)liStop.QuadPart - (double)liStart.QuadPart) / (double)liFreq.QuadPart);
}
void Reset()
{
liStart.QuadPart = liStop.QuadPart = 0;
}
};
void main()
{
StopWatch sw;
double dElapsed, dInterval = 0.0625; // 1/16 sec.
static char* sza[] = {
"PROMPT->%c\r",
"PROMPT\\>%c\r",
"PROMPT|>%c\r",
"PROMPT/>%c\r"
};
long i=0;
char c = ' ';
puts("Press Q to quit...\n"

;
sw.Start();
while(1){
if(kbhit()){
c = toupper(getch());
if(c == 'Q')return;
}
dElapsed = sw.Stop();
if(dElapsed < dInterval){
continue;
}else{
printf(sza[i++], c);
if(i == 4) i = 0;
sw.Start();
}
}
}
If you need very preciese interval measurement within a loop, this class can do the trick. Using StopWatch in a separate thread you can build your own calling back timer.
MSDN Library says (at 'QueryPerformanceFrequency' pages)that not all systems have a performance counter available. But I guess most all pentium class pc's do.