|
VLink
2.0.0
A high-performance communication middleware
|
Lowest-level elapsed-time primitive used by deadline tracking, profilers and task metrics. More...
Go to the source code of this file.
Classes | |
| class | vlink::ElapsedTimer |
| Atomic high-resolution timer with selectable clock source and unit. More... | |
Namespaces | |
| vlink | |
Lowest-level elapsed-time primitive used by deadline tracking, profilers and task metrics.
ElapsedTimer measures how much time has passed since start was called, using either a monotonic wall clock or process CPU time, with millisecond / microsecond / nanosecond resolution. It backs DeadlineTimer, CpuProfiler and the message-loop task latency counters.
| Method | Purpose | Mutates state |
|---|---|---|
start | Latch the current time as the start reference | yes |
stop | Mark the timer inactive (start = -1) | yes |
restart | Read elapsed, latch new start atomically | yes |
get | Read elapsed without changing state | no |
is_active | Report whether start has set the reference | no |
get_sys_timestamp | Sample wall-clock time (CLOCK_REALTIME) | no |
get_cpu_timestamp | Sample monotonic time (CLOCK_MONOTONIC_RAW) | no |
get_cpu_active_time | Sample cumulative process CPU time | no |
| Value | Clock source | Notes |
|---|---|---|
| kCpuTimestamp | std::chrono::steady_clock | Monotonic wall time, never jumps |
| kCpuActiveTime | getrusage / GetProcessTimes | Total process user + kernel time |
| Value | Unit | 64-bit dynamic range |
|---|---|---|
| kMilli | milliseconds | ~292 million years |
| kMicro | microseconds | ~292 thousand years |
| kNano | nanoseconds | ~292 years |
start explicitly. The internal start time is held in a 64-byte aligned std::atomic<int64_t>; concurrent reads are safe, but interleaved start / stop from different threads race on the active flag.