From 68a91426fb0ec227348ad8fffd53da80a6dc916c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Tue, 16 Feb 2016 09:25:10 +0100 Subject: [PATCH] tests/xtimer_drift: Compute drift and jitter - drift is the total difference from the expected time - jitter is the difference only since the last printout --- tests/xtimer_drift/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/xtimer_drift/main.c b/tests/xtimer_drift/main.c index 69e1b02eab..6e4aaf2830 100644 --- a/tests/xtimer_drift/main.c +++ b/tests/xtimer_drift/main.c @@ -89,6 +89,7 @@ void *worker_thread(void *arg) (void) arg; unsigned int loop_counter = 0; uint32_t start = 0; + uint32_t last = 0; printf("Starting thread %" PRIkernel_pid "\n", thread_getpid()); @@ -98,6 +99,9 @@ void *worker_thread(void *arg) uint32_t now = xtimer_now(); if (start == 0) { start = now; + last = start; + ++loop_counter; + continue; } uint32_t us, sec; @@ -108,9 +112,12 @@ void *worker_thread(void *arg) hr = sec / 3600; if ((loop_counter % TEST_HZ) == 0) { uint32_t expected = start + loop_counter * TEST_INTERVAL; - int32_t diff = now - expected; - printf("now=%" PRIu32 ".%06" PRIu32 " (%u hours %u min), diff=%" PRId32 "\n", - sec, us, hr, min, diff); + int32_t drift = now - expected; + expected = last + TEST_HZ * TEST_INTERVAL; + int32_t jitter = now - expected; + printf("now=%" PRIu32 ".%06" PRIu32 " (%u hours %u min), drift=%" PRId32 ", jitter=%" PRId32 "\n", + sec, us, hr, min, drift, jitter); + last = now; } ++loop_counter; }