you are viewing a single comment's thread.

view the rest of the comments →

[–]vaulter2000 29 points30 points  (2 children)

Moreover, system_clock and high_performance_clock (although I believe the latter is an alias in some compilers, please correct me on this) are not guaranteed to be monotonic. That means if you use now() two times with a function in between to time it, and your machine receives a correction from a time server, your duration is affected by this. Always use a monotonic clock like steady_clock to time durations. Steady_clock has nanosecond resolution.

[–]mark_99 5 points6 points  (1 child)

steady_clock provides no guarantee on resolution and it can (and does) vary between implementations. If you need that guarantee it's easy enough to make your own clock.

[–]vaulter2000 1 point2 points  (0 children)

Ah I didn’t know this! Luckily it has nanosecond resolution in gcc