Header: libxs_timer.h
High-resolution timing via a calibrated TSC when available, with an OS real-time clock fallback.
typedef unsigned long long libxs_timer_tick_t;Integer type representing a single timer sample.
typedef struct libxs_timer_info_t {
int tsc; /* non-zero if a calibrated TSC is used */
} libxs_timer_info_t;int libxs_timer_info(libxs_timer_info_t* info);Query timer properties. info->tsc is non-zero when RDTSC (x86), CNTVCT_EL0 (AArch64), or MFTB (PPC64) is available. Triggers lazy library initialization if necessary.
libxs_timer_tick_t libxs_timer_tick(void);Sample the current tick of the monotonic timer. The tick unit is platform-specific; convert with libxs_timer_duration or libxs_timer_ncycles.
libxs_timer_tick_t libxs_timer_ncycles(
libxs_timer_tick_t tick0, libxs_timer_tick_t tick1); /* inline */Unsigned difference tick1 - tick0, handling wrap-around safely. Implemented via LIBXS_DELTA.
double libxs_timer_duration(
libxs_timer_tick_t tick0, libxs_timer_tick_t tick1);Convert a pair of ticks to elapsed wall-clock time in seconds.