mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-06 04:04:17 +03:00
use CLOCK_MONOTONIC in the timer if it's available
Linux sets _POSIX_MONOTONIC_CLOCK to 0 meaning it *might* be available, so a sysconf check is necessary at runtime with a fallback to the mandatory CLOCK_REALTIME clock.
This commit is contained in:
parent
f69e2f6fda
commit
d6384b09e1
2 changed files with 27 additions and 0 deletions
|
|
@ -1,10 +1,20 @@
|
|||
/* 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 {
|
||||
#if JEMALLOC_CLOCK_GETTIME
|
||||
struct timespec tv0;
|
||||
struct timespec tv1;
|
||||
int clock_id;
|
||||
#else
|
||||
struct timeval tv0;
|
||||
struct timeval tv1;
|
||||
#endif
|
||||
} timedelta_t;
|
||||
|
||||
void timer_start(timedelta_t *timer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue