A monotonic timestamp based on std::chrono::steady_clock. More...
#include <timestamp.h>
Public Types | |
| using | Clock = std::chrono::steady_clock |
| Underlying clock type. | |
| using | Value = std::chrono::time_point< Clock > |
| Time point value type. | |
| using | Duration = Clock::duration |
| Duration type derived from the clock. | |
Public Member Functions | |
| TimeStamp () | |
| Constructs a default (epoch) TimeStamp. | |
| TimeStamp (const Value &v) | |
| Constructs a TimeStamp from the given time point value. | |
| operator Value () const | |
| Converts the TimeStamp to its underlying Value type. | |
| TimeStamp & | operator+= (const Duration &duration) |
| Advances the timestamp by the given duration. | |
| TimeStamp & | operator-= (const Duration &duration) |
| Moves the timestamp back by the given duration. | |
| void | setValue (const Value &v) |
| Sets the underlying time point value. | |
| Value | value () const |
| Returns the underlying time point value. | |
| void | update () |
| Updates the timestamp to the current time. | |
| void | sleepUntil () const |
| Sleeps the current thread until this timestamp is reached. | |
| Duration | timeSinceEpoch () const |
| Returns the duration since the clock's epoch. | |
| double | seconds () const |
| Returns the time since epoch in seconds as a double. | |
| int64_t | milliseconds () const |
| Returns the time since epoch in milliseconds. | |
| int64_t | microseconds () const |
| Returns the time since epoch in microseconds. | |
| int64_t | nanoseconds () const |
| Returns the time since epoch in nanoseconds. | |
| double | elapsedSeconds () const |
| Returns the elapsed time since this timestamp in seconds. | |
| int64_t | elapsedMilliseconds () const |
| Returns the elapsed time since this timestamp in milliseconds. | |
| int64_t | elapsedMicroseconds () const |
| Returns the elapsed time since this timestamp in microseconds. | |
| int64_t | elapsedNanoseconds () const |
| Returns the elapsed time since this timestamp in nanoseconds. | |
| String | toString () const |
| Returns a string representation of the timestamp in seconds. | |
| operator String () const | |
| Converts the TimeStamp to a String. | |
Static Public Member Functions | |
| static Duration | secondsToDuration (double val) |
| Converts a floating-point number of seconds to a Duration. | |
| static void | sleep (const Duration &d) |
| Sleeps the current thread for the given duration. | |
| static TimeStamp | now () |
| Returns a TimeStamp representing the current time. | |
A monotonic timestamp based on std::chrono::steady_clock.
Provides high-resolution time measurement, elapsed time queries, and thread sleep utilities. Uses steady_clock to guarantee monotonic
Constructs a TimeStamp from the given time point value.
| v | The time point value. |
|
inline |
Returns the elapsed time since this timestamp in microseconds.
|
inline |
Returns the elapsed time since this timestamp in milliseconds.
|
inline |
Returns the elapsed time since this timestamp in nanoseconds.
|
inline |
Returns the elapsed time since this timestamp in seconds.
|
inline |
Returns the time since epoch in microseconds.
|
inline |
Returns the time since epoch in milliseconds.
|
inline |
Returns the time since epoch in nanoseconds.
Advances the timestamp by the given duration.
| duration | The duration to add. |
Moves the timestamp back by the given duration.
| duration | The duration to subtract. |
|
inline |
Returns the time since epoch in seconds as a double.
Sets the underlying time point value.
| v | The new time point value. |
Sleeps the current thread for the given duration.
| d | The duration to sleep. |
|
inline |
Returns the duration since the clock's epoch.
|
inline |
Returns a string representation of the timestamp in seconds.
|
inline |
Returns the underlying time point value.