Browse Source

tests: enhance xtimer_now64_continuity

- adapt code to use public, typesafe API calls
    - add some statistical output
    - minor code enhancements and doc corrections
    - use fmt print_str for uint64_t
pr/rotary
smlng 5 years ago
parent
commit
e72426a67d
  1. 1
      tests/xtimer_now64_continuity/Makefile
  2. 5
      tests/xtimer_now64_continuity/README.md
  3. 42
      tests/xtimer_now64_continuity/main.c

1
tests/xtimer_now64_continuity/Makefile

@ -1,6 +1,7 @@
APPLICATION = xtimer_now64_continuity
include ../Makefile.tests_common
USEMODULE += fmt
USEMODULE += xtimer
include $(RIOTBASE)/Makefile.include

5
tests/xtimer_now64_continuity/README.md

@ -1,5 +1,6 @@
Description
===========
This test measures the difference of two consecutive calls to xtimer_now64() 10k times.
Should the difference be larger then 1000us, the test fails, otherwise it succeeds.
This test measures the difference of two consecutive calls to xtimer_now64()
100k times. If the max or average difference is larger than 1000us the test
fails, otherwise it succeeds.

42
tests/xtimer_now64_continuity/main.c

@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
* 2017 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@ -14,35 +15,50 @@
* @brief xtimer_now64 continuity test application
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Sebastian Meiling <s@mlng.net>
*
* @}
*/
#include <stdio.h>
#include <stdint.h>
#include "xtimer.h"
#include "fmt.h"
#define ITERATIONS (100000LU)
#define MAXDIFF 1000
#define ITERATIONS (100000LU)
#define MAXDIFF (1000U)
int main(void)
{
uint32_t n = ITERATIONS;
uint64_t before = _xtimer_now64();
uint64_t diff_min = UINT64_MAX;
uint64_t diff_max = 0;
uint64_t diff_sum = 0;
xtimer_ticks64_t before = xtimer_now64();
print_str("[START]\n");
while(--n) {
uint64_t now = _xtimer_now64();
if ((now-before) > MAXDIFF) {
puts("TEST FAILED.");
break;
xtimer_ticks64_t now = xtimer_now64();
xtimer_ticks64_t diff = xtimer_diff64(now, before);
if (diff.ticks64 > diff_max) {
diff_max = diff.ticks64;
}
if (diff.ticks64 < diff_min) {
diff_min = diff.ticks64;
}
diff_sum += diff.ticks64;
before = now;
}
if (!n) {
puts("TEST SUCCESSFUL.");
print_str("[RESULTS] min=");
print_u64_dec(diff_min);
print_str(", avg=");
print_u64_dec(diff_sum/ITERATIONS);
print_str(", max=");
print_u64_dec(diff_max);
print_str("\n");
if ((diff_max > MAXDIFF) || (diff_sum/ITERATIONS > MAXDIFF)) {
print_str("[FAILURE]\n");
return 1;
}
print_str("[SUCCESS]\n");
return 0;
}

Loading…
Cancel
Save