timer.h#

#include <sif/utils/timer.h>
SIF_UTILS_TIMER_H#

Monotonic wall-clock timer used for the library’s own timings.

struct sif_timer_t#

A start/stop pair of monotonic timestamps.

Monotonic rather than calendar time, so a clock adjustment mid-run cannot produce a negative interval.

void sif_timer_start(sif_timer_t *timer)#

Start, or restart, the timer.

Parameters:
  • timer – Timer to stamp.

void sif_timer_stop(sif_timer_t *timer)#

Stop the timer, fixing the interval.

Parameters:
  • timer – Timer previously passed to sif_timer_start().

double sif_timer_elapsed_ms(const sif_timer_t *timer)#

Elapsed time between the last start and the last stop.

Returns double rather than sif_real deliberately: a duration is not a physical field quantity, and milliseconds at float precision would quantize visibly over a long run.

Parameters:
  • timer – Timer to read.

Returns:

Elapsed time in milliseconds, or -1.0 if timer is NULL.

Warning

Only meaningful once sif_timer_stop() has been called. Reading a timer that was started but never stopped returns whatever the uninitialized stop timestamp held.