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 #ifdef _WIN32
11 	FILETIME ft0;
12 	FILETIME ft1;
13 #elif JEMALLOC_CLOCK_GETTIME
14 	struct timespec ts0;
15 	struct timespec ts1;
16 	int clock_id;
17 #else
18 	struct timeval tv0;
19 	struct timeval tv1;
20 #endif
21 } timedelta_t;
22 
23 void	timer_start(timedelta_t *timer);
24 void	timer_stop(timedelta_t *timer);
25 uint64_t	timer_usec(const timedelta_t *timer);
26 void	timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen);
27