284 [[nodiscard]] int64_t
get() const noexcept;
287 alignas(64)
std::atomic<int64_t> start_time_{-1};
288 Method method_{kCpuTimestamp};
289 Accuracy accuracy_{kMilli};
void start() noexcept
Starts the timer if it is not already active.
static uint64_t get_cpu_active_time(Accuracy accuracy=kMilli) noexcept
Returns the accumulated CPU time (user + kernel) consumed by the current process.
bool is_active() const noexcept
Returns true when the timer has been started and not yet stopped.
static uint64_t get_cpu_timestamp(Accuracy accuracy=kMilli, bool high_resolution=true) noexcept
Returns the current monotonic CPU timestamp.
int64_t get() const noexcept
Returns the elapsed time since start() was called.
int64_t restart() noexcept
Atomically resets the start time to now and returns the elapsed time since the previous start() / res...
Accuracy
Selects the precision (resolution) of the timer values returned.
Definition elapsed_timer.h:106
@ kNano
Nanosecond precision.
Definition elapsed_timer.h:109
@ kMilli
Millisecond precision.
Definition elapsed_timer.h:107
@ kMicro
Microsecond precision.
Definition elapsed_timer.h:108
ElapsedTimer() noexcept
Constructs an ElapsedTimer with default method (kCpuTimestamp) and default accuracy (kMilli).
Accuracy get_accuracy() const noexcept
Returns the precision configured for this timer.
void stop() noexcept
Stops the timer, setting the internal start time to -1.
Method get_method() const noexcept
Returns the clock source configured for this timer.
static uint64_t get_sys_timestamp(Accuracy accuracy=kMilli, bool high_resolution=true) noexcept
Returns the current wall-clock (system) timestamp.
Method
Selects the underlying clock source for time measurement.
Definition elapsed_timer.h:98
@ kCpuTimestamp
Monotonic wall-clock (CLOCK_MONOTONIC_RAW on Linux).
Definition elapsed_timer.h:99
@ kCpuActiveTime
Process CPU time (user + kernel, via getrusage).
Definition elapsed_timer.h:100
Platform-independent macro definitions for the VLink library.
#define VLINK_EXPORT
Definition macros.h:85