If I have the following clock and use it to get a count of ticks since the clock's epoch, what does this count actually represent.
std::chrono::high_resolution_clock::now().time_since_epoch().count();
For instance I just ran this and got 1389375799048790227
. What does this number mean? Is it nanoseconds, microseconds, etc?
Class template std::chrono::duration represents a time interval. It consists of a count of ticks of type Rep and a tick period, where the tick period is a compile-time rational fraction representing the time in seconds from one tick to the next. The only data stored in a duration is a tick count of type Rep .
Time since epoch. Returns a duration object with the time span value between the epoch and the time point. The value returned is the current value of the internal duration object.
Class template std::chrono::time_point represents a point in time. It is implemented as if it stores a value of type Duration indicating the time interval from the start of the Clock 's epoch. Clock must meet the requirements for Clock or be std::chrono::local_t (since C++20).
In a computing context, an epoch is the date and time relative to which a computer's clock and timestamp values are determined. The epoch traditionally corresponds to 0 hours, 0 minutes, and 0 seconds (00:00:00) Coordinated Universal Time (UTC) on a specific date, which varies from system to system.
The type of the duration is std::chrono::high_resolution_clock::duration
. You can inspect a duration's tick period with: std::chrono::high_resolution_clock::duration::period::num
and std::chrono::high_resolution_clock::duration::period::den
. This is the numerator and denominator of a fraction representing the amount of seconds per tick (e.g. 1/1000000000 for nanoseconds).
The epoch is unspecified, but for you is 1389375799048790227 ticks from when you got that result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With