mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #6735 from smlng/tests/xtimer_now64_cont
tests: enhance xtimer_now64_continuity
This commit is contained in:
commit
20d5c3ee5a
@ -1,6 +1,7 @@
|
||||
APPLICATION = xtimer_now64_continuity
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += fmt
|
||||
USEMODULE += xtimer
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -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.
|
||||
|
@ -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…
Reference in New Issue
Block a user