Search⌘ K

Clocks

Explore the three types of clocks available in the C++ time library, including system_clock, steady_clock, and high_resolution_clock. Understand their characteristics, accuracy, steadiness, and typical epochs. Learn how to use these clocks for timing, measuring durations, and managing multi-threading delays effectively.

We'll cover the following...

The fact that there are three different types of clocks begs the question: What are the differences?

  • std::chrono::system_clock: is the system-wide real time clock (wall-clock). The clock has the auxiliary functions to_time_t and from_time_t to convert time points into calendar time

  • std::chrono::steady_clock: is the only clock to provide the guarantee that you can not adjust it. Therefore, std::chrono::steady_clock is the preferred clock to wait for a time duration or until a time point

  • std::chrono::high_resolution_clock: is the ...