9bad079039
Use a single uint64_t in nstime_t to store nanoseconds rather than using struct timespec. This reduces fragility around conversions between long and uint64_t, especially missing casts that only cause problems on 32-bit platforms.
15 lines
355 B
C
15 lines
355 B
C
/* Simple timer, for use in benchmark reporting. */
|
|
|
|
#include <unistd.h>
|
|
#include <sys/time.h>
|
|
|
|
typedef struct {
|
|
nstime_t t0;
|
|
nstime_t t1;
|
|
} timedelta_t;
|
|
|
|
void timer_start(timedelta_t *timer);
|
|
void timer_stop(timedelta_t *timer);
|
|
uint64_t timer_usec(const timedelta_t *timer);
|
|
void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen);
|