clock: prefer clock monotonic

Various articles claim that CLOCK_MONOTONIC is actually faster than the
CLOCK_MONOTONIC_RAW, and that seems to be my experience.
This commit is contained in:
Christian Hergert
2018-05-16 12:28:42 +01:00
parent ac11f0f941
commit f8176b699b

View File

@ -24,18 +24,17 @@ void
sp_clock_init (void) sp_clock_init (void)
{ {
static const gint clock_ids[] = { static const gint clock_ids[] = {
CLOCK_MONOTONIC,
CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_RAW,
CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE,
CLOCK_MONOTONIC,
CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE,
CLOCK_REALTIME, CLOCK_REALTIME,
}; };
guint i;
if (sp_clock != -1) if (sp_clock != -1)
return; return;
for (i = 0; i < G_N_ELEMENTS (clock_ids); i++) for (guint i = 0; i < G_N_ELEMENTS (clock_ids); i++)
{ {
struct timespec ts; struct timespec ts;
int clock_id = clock_ids [i]; int clock_id = clock_ids [i];