Search code examples
c++windowstiming

Measuring time with a resolution of microseconds in C++?


I'm looking for a way to measure microsecs in C++/Windows.

I read about the "clock" function, but it returns only milliseconds...
Is there a way to do it?


Solution

  • Use QueryPerformanceCounter and QueryPerformanceFrequency for finest grain timing on Windows.

    MSDN article on code timing with these APIs here (sample code is in VB - sorry).