mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 06:59:32 +03:00
prefer monotonic clock for stats (issue #457)
This commit is contained in:
parent
6ef15943cc
commit
d6bbc08119
1 changed files with 5 additions and 1 deletions
|
@ -412,10 +412,14 @@ mi_msecs_t _mi_clock_now(void) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef CLOCK_REALTIME
|
#if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC)
|
||||||
mi_msecs_t _mi_clock_now(void) {
|
mi_msecs_t _mi_clock_now(void) {
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
|
#ifdef CLOCK_MONOTONIC
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||||
|
#else
|
||||||
clock_gettime(CLOCK_REALTIME, &t);
|
clock_gettime(CLOCK_REALTIME, &t);
|
||||||
|
#endif
|
||||||
return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000);
|
return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue