From d6bbc0811923cd8560f636224be71fbbd739b576 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 18 Oct 2021 18:24:59 -0700 Subject: [PATCH] prefer monotonic clock for stats (issue #457) --- src/stats.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stats.c b/src/stats.c index ac728a1c..662da53e 100644 --- a/src/stats.c +++ b/src/stats.c @@ -412,10 +412,14 @@ mi_msecs_t _mi_clock_now(void) { } #else #include -#ifdef CLOCK_REALTIME +#if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC) mi_msecs_t _mi_clock_now(void) { struct timespec t; + #ifdef CLOCK_MONOTONIC + clock_gettime(CLOCK_MONOTONIC, &t); + #else clock_gettime(CLOCK_REALTIME, &t); + #endif return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000); } #else