std::chrono...ution_clock(3)
πΈ NAME πΈ
std::chrono::high_resolution_clock β std::chrono::high_resolution_clock
Okay bestie, this is the C++ Standard Libary page for std::chrono...ution_clock(3), and the NAME section is literally doubling the same name like a mirror selfie π
. We're talking about std::chrono::high_resolution_clock, and it's kind of a main-character clock.
β¨ Synopsis β¨
Defined in header <chrono>
class high_resolution_clock; (since C++11)
Class std::chrono::high_resolution_clock represents the clock with the smallest tick period provided by the implementation. It may be an alias of std::chrono::system_clock or std::chrono::steady_clock, or a third, independent clock.
And yes, std::chrono::high_resolution_clock meets the requirements of TrivialClock. Slay π«Ά.
π Member types π
repβ arithmetic type representing the number of ticks in the clock's durationperiodβ astd::ratiotype representing the tick period of the clock, in secondsdurationβstd::chrono::duration<rep, period>time_pointβstd::chrono::time_point<std::chrono::high_resolution_clock>
π« Member constants π«
constexpr bool is_steady[static]βtrueif the time between ticks is always constant, i.e. calls tonow()return values that increase monotonically even in case of some external clock adjustment, otherwisefalse; this is a public static member constant
π₯ Member functions π₯
now[static]β returns astd::chrono::time_pointrepresenting the current value of the clock; public static member function
π Notes π
There has been some controversy around the use of high_resolution_clock. Howard Hinnant, who claims to have introduced high_resolution_clock to the language, stated in 2016 on the ISO C++ Standard - Discussion mailing list that he was in favor of deprecating it. His rationale was that, because the standard allows for it to be an alias for std::chrono::steady_clock or std::chrono::system_clock, its use adds uncertainty to a program without benefit. However, other participants in the thread spoke out in its favor, for instance on the basis that, because neither std::chrono::steady_clock nor std::chrono::system_clock come with any particular resolution guarantees, high_resolution_clock serves a useful role by giving the vendor an opportunity to supply the platform's highest-resolution clock, when neither its std::chrono::steady_clock nor its std::chrono::system_clock would be that.
It is often just an alias for std::chrono::steady_clock or std::chrono::system_clock, but which one it is depends on the library or configuration. When it is a system_clock, it is not monotonic (e.g., the time can go backwards). For example, as of 2023, libstdc++ has it aliased to system_clock "until higher-than-nanosecond definitions become feasible"^[1], MSVC has it as steady_clock^[2], and libc++ uses steady_clock when the C++ standard library implementation supports a monotonic clock and system_clock otherwise^[3].
Vibe check: this clock might be a total icon, or it might lowkey be wearing a system_clock disguise. Check your library, bestie π.
π See also π
system_clockβ wall clock time from the system-wide realtime clock (C++11) (class)steady_clockβ monotonic clock that will never be adjusted (C++11) (class)
π External links π
- β libstdc++
<chrono.h> - β msvc
high_resolution_clock - β libc++
<high_resolution_clock.h>
Bye bestie! This was std::chrono...ution_clock(3) from http://cppreference.com, dated 2024.06.10. Stay steady β or not, depending on your alias β periodt πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms