summaryrefslogtreecommitdiff
path: root/deps/jemalloc/test/include/test/timer.h
blob: a7fefdfd1bbbcbbaff67d0688ed4a0d38564f4ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Simple timer, for use in benchmark reporting. */

#include <unistd.h>
#include <sys/time.h>

#define JEMALLOC_CLOCK_GETTIME defined(_POSIX_MONOTONIC_CLOCK) \
    && _POSIX_MONOTONIC_CLOCK >= 0

typedef struct {
#ifdef _WIN32
	FILETIME ft0;
	FILETIME ft1;
#elif JEMALLOC_CLOCK_GETTIME
	struct timespec ts0;
	struct timespec ts1;
	int clock_id;
#else
	struct timeval tv0;
	struct timeval tv1;
#endif
} 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);