From ce3685f0017282090a70583933543c93f4bec1d3 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Thu, 10 Nov 2016 14:36:10 +0900 Subject: [PATCH] evlog - reduce overhead of getting time a little by pre-checking clock this checks for clock_gettime + CLOCK_MONOTONIC or CLOCK_REALTIME at evlog init to avoid a cmp+brang and l1 instr cache hit every get. slightly less overhead when this is on. --- src/lib/eina/eina_evlog.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/eina/eina_evlog.c b/src/lib/eina/eina_evlog.c index a4e3f67b9e..1e87391790 100644 --- a/src/lib/eina/eina_evlog.c +++ b/src/lib/eina/eina_evlog.c @@ -60,14 +60,6 @@ get_time(void) #if defined (HAVE_CLOCK_GETTIME) || defined (EXOTIC_PROVIDE_CLOCK_GETTIME) struct timespec t; - if (EINA_UNLIKELY(_eina_evlog_time_clock_id < 0)) - { - if (!clock_gettime(CLOCK_MONOTONIC, &t)) - _eina_evlog_time_clock_id = CLOCK_MONOTONIC; - else - _eina_evlog_time_clock_id = CLOCK_REALTIME; - } - if (EINA_UNLIKELY(clock_gettime(_eina_evlog_time_clock_id, &t))) { struct timeval timev; @@ -226,6 +218,16 @@ eina_evlog_init(void) { eina_spinlock_new(&_evlog_lock); buf = &(buffers[0]); +#if defined (HAVE_CLOCK_GETTIME) || defined (EXOTIC_PROVIDE_CLOCK_GETTIME) + { + struct timespec t; + + if (!clock_gettime(CLOCK_MONOTONIC, &t)) + _eina_evlog_time_clock_id = CLOCK_MONOTONIC; + else + _eina_evlog_time_clock_id = CLOCK_REALTIME; + } +#endif eina_evlog("+eina_init", NULL, 0.0, NULL); return EINA_TRUE; }