summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-10 14:36:10 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-10 16:22:34 +0900
commitce3685f0017282090a70583933543c93f4bec1d3 (patch)
treeaf560ec06797bb920b89e62b0bb94d789c549fca
parent42ebfa863fbd99b89c4d220d3b414a0d5cedca8c (diff)
downloadefl-ce3685f0017282090a70583933543c93f4bec1d3.tar.gz
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.
-rw-r--r--src/lib/eina/eina_evlog.c18
1 files 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;
}