c++ - Does steady_clock have only 10ms resolution on windows/cygwin? -
i have suprising observation steady_clock gives poor 10ms resolution when measuring durations. compile windows under cygwin. sad true or doing sth wrong?
auto start = std::chrono::steady_clock::now(); /*...*/ auto end = std::chrono::steady_clock::now(); std::cout << std::chrono::duration_cast<std::chrono::microseconds> (end - start).count();
result 10000,20000 etc.
the resolution of std::steady_clock
implementation dependent, , shouldn't rely on precise minimum duration. varies across platforms/compiler implementations.
from http://cppreference.com:
class std::chrono::steady_clock represents monotonic clock. time points of clock cannot decrease physical time moves forward. clock not related wall clock time, , best suitable measuring intervals.
related: difference between std::system_clock , std::steady_clock?
if don't care monotonicity (i.e., don't care if changes wall clock while program running), you're better off std::high_resolution_clock. (the latter still implementation-dependent)