Helper function bpf_ktime_get_coarse_ns
Definition
Copyright (c) 2015 The Libbpf Authors. All rights reserved.
Return a coarse-grained version of the time elapsed since system boot, in nanoseconds. Does not include time the system was suspended.
See: clock_gettime(CLOCK_MONOTONIC_COARSE)
Returns
Current ktime.
static __u64 (* const bpf_ktime_get_coarse_ns)(void) = (void *) 160;
Usage
This function returns a coarse-grained 64-bit timestamp in nanoseconds since system boot, excluding suspended time. It is similar to bpf_ktime_get_ns()
, but offers lower precision in exchange for better performance. It is suitable for low-overhead time measurements.
Program types
This helper call can be used in the following program types:
Example
__u64 start_time = bpf_ktime_get_coarse_ns();
/* some tasks */
__u64 end_time = bpf_ktime_get_coarse_ns();
__u64 duration = end_time - start_time;