1 /* Simple timer, for use in benchmark reporting. */ 2 3 #include <unistd.h> 4 #include <sys/time.h> 5 6 #define JEMALLOC_CLOCK_GETTIME defined(_POSIX_MONOTONIC_CLOCK) \ 7 && _POSIX_MONOTONIC_CLOCK >= 0 8 9 typedef struct { 10 #if JEMALLOC_CLOCK_GETTIME 11 struct timespec tv0; 12 struct timespec tv1; 13 int clock_id; 14 #else 15 struct timeval tv0; 16 struct timeval tv1; 17 #endif 18 } timedelta_t; 19 20 void timer_start(timedelta_t *timer); 21 void timer_stop(timedelta_t *timer); 22 uint64_t timer_usec(const timedelta_t *timer); 23 void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen); 24