Also, clock() measures program time, not real time. If your program spends a lot of time sleeping or waiting for things to happen, then clock() will lag.

Basically, anything sub-second is specific to your OS/Compiler. So say what you have if you want a more specific answer.

11-17-2003

Rainer

I want to be able to run my program in any win32 environment (since it's ANSI, it shouldn't matter, right?) and I have the worst compiler out there, Dev version 4. I've been meaning to get a better one...

11-18-2003

DougDbug

If you need about a half-second you should be OK most of the time...

However, you simply cannot count on accurate timing (in user mode) with a multi-tasking operating system. In user mode, another program can interrupt your program at any time... maybe in the middle of your half-second count... When it returns to your program, it may be two seconds later. To get total control of the system, and lock-out other concurrent processes and interrupts, you have to get into the kernel mode. (Not easy stuff... and I don't know how to do it.)

There is a Windows function, I think it's GetTickCount(), that will return milliseconds accurately (at the time it's executed). But, of course that function will only execute during your program's time-slice.