I\'m using time.h in C++ to measure the timing of a function.
clock_t t = clock();
someFunction();
printf(\"\\nTime taken: %.4fs\\n\", (float)(clock() - t)/
The following text, that i completely agree with, is quoted from Optimizing software in C++ (good reading for any C++ programmer) -
The time measurements may require a very high resolution if time intervals are short. In Windows, you can use the
GetTickCountorQueryPerformanceCounterfunctions for millisecond resolution. A much higher resolution can be obtained with the time stamp counter in the CPU, which counts at the CPU clock frequency.
There is a problem that "the clock frequency may vary dynamically and that measurements are unstable due to interrupts and task switches."