Quote Originally Posted by wysota View Post
The process can be preemptied practically at any time to yield the CPU to some other process which makes results of such primitive calculations incorrect. The difference between those two measurements is "how much time it took to execute the code" and "how much time it took to execute the code in particular conditions" where "particular conditions" are impossible to recreate, so the measurement is not representative.
I've been thinking about this some more: does this mean that using clock() would, for a program like the above, always return the same results, no matter what the system load is?
There's no sleep or waiting conditions, only one thread, so the code executed should always follow the exact same path, so using clock() in the places where I used QueryPerformanceCounter() should always return the exact same value, or is there a pitfall of some kind?