2016-01-06 13:58:36 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
2017-03-10 17:28:01 +01:00
|
|
|
* 2017 HAW Hamburg
|
2016-01-06 13:58:36 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup tests
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief xtimer_now64 continuity test application
|
|
|
|
*
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
2017-03-10 17:28:01 +01:00
|
|
|
* @author Sebastian Meiling <s@mlng.net>
|
2016-01-06 13:58:36 +01:00
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "xtimer.h"
|
2017-03-10 17:28:01 +01:00
|
|
|
#include "fmt.h"
|
2016-01-06 13:58:36 +01:00
|
|
|
|
2017-03-10 17:28:01 +01:00
|
|
|
#define ITERATIONS (100000LU)
|
|
|
|
#define MAXDIFF (1000U)
|
2016-01-06 13:58:36 +01:00
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
uint32_t n = ITERATIONS;
|
2017-03-10 17:28:01 +01:00
|
|
|
uint64_t diff_min = UINT64_MAX;
|
|
|
|
uint64_t diff_max = 0;
|
|
|
|
uint64_t diff_sum = 0;
|
|
|
|
print_str("[START]\n");
|
2018-05-16 16:49:03 +02:00
|
|
|
xtimer_ticks64_t before = xtimer_now64();
|
2016-01-06 13:58:36 +01:00
|
|
|
while(--n) {
|
2017-03-10 17:28:01 +01:00
|
|
|
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;
|
2016-01-06 13:58:36 +01:00
|
|
|
}
|
2017-03-10 17:28:01 +01:00
|
|
|
diff_sum += diff.ticks64;
|
2016-01-06 13:58:36 +01:00
|
|
|
before = now;
|
|
|
|
}
|
2017-03-10 17:28:01 +01:00
|
|
|
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;
|
2016-01-06 13:58:36 +01:00
|
|
|
}
|
2017-03-10 17:28:01 +01:00
|
|
|
print_str("[SUCCESS]\n");
|
2016-01-06 13:58:36 +01:00
|
|
|
return 0;
|
|
|
|
}
|