MULE 0.0.1
Multi-Use Library Essentials
Loading...
Searching...
No Matches
Time

Overview

A monotonic clock for measuring how long things take.

time_now_ns() reads CLOCK_MONOTONIC. It never goes backwards, so the difference between two readings is a duration even when the wall clock changes. It does not tell the time of day.

uint64_t start = time_now_ns();
nanosleep(&(struct timespec){ .tv_nsec = 2000000 }, NULL); /* 2 ms */
uint64_t elapsed = time_now_ns() - start;

Functions

uint64_t time_now_ns (void)
 Nanoseconds on a monotonic clock.

Function Documentation

◆ time_now_ns()

uint64_t time_now_ns ( void )

Nanoseconds on a monotonic clock.

It never goes backwards, but its zero is arbitrary, so only the difference between two readings means anything.

Definition at line 5 of file time.c.