From 6f729383a8505baae57a4bcc81231d40d9dc340b Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 18 Aug 2020 20:07:46 -0400 Subject: [PATCH] tests: timestamp: minor cleanup Minor cleanup and fixes. Signed-off-by: Anas Nashif --- subsys/testsuite/include/timestamp.h | 18 +++++++++--------- tests/benchmarks/sys_kernel/src/syskernel.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/subsys/testsuite/include/timestamp.h b/subsys/testsuite/include/timestamp.h index 7bd6c75c575..96d432c8a33 100644 --- a/subsys/testsuite/include/timestamp.h +++ b/subsys/testsuite/include/timestamp.h @@ -23,7 +23,7 @@ #endif -#define TICK_SYNCH() k_sleep(K_MSEC(1)) +#define TICK_SYNCH() k_sleep(K_TICKS(1)) #define OS_GET_TIME() k_cycle_get_32() @@ -59,27 +59,27 @@ static inline void bench_test_init(void) /* timestamp for checks */ -static int64_t tCheck; +static int64_t timestamp_check; /* * Routines are invoked before and after the benchmark and check - * if penchmarking code took less time than necessary for the + * if benchmarking code took less time than necessary for the * high precision timer register overflow. - * Functions modify the tCheck global variable. + * Functions modify the timestamp_check global variable. */ static inline void bench_test_start(void) { - tCheck = 0; + timestamp_check = 0; /* before reading time we synchronize to the start of the timer tick */ TICK_SYNCH(); - tCheck = k_uptime_delta(&tCheck); + timestamp_check = k_uptime_delta(×tamp_check); } /* returns 0 if the completed within a second and -1 if not */ static inline int bench_test_end(void) { - tCheck = k_uptime_delta(&tCheck); + timestamp_check = k_uptime_delta(×tamp_check); /* Flag an error if the test ran for more than a second. * (Note: Existing benchmarks have CONFIG_SYS_CLOCK_TICKS_PER_SEC=1 set, @@ -87,7 +87,7 @@ static inline int bench_test_end(void) * timer tick interrupt overheads too are getting accounted towards * benchmark time) */ - if (tCheck >= MSEC_PER_SEC) { + if (timestamp_check >= MSEC_PER_SEC) { return -1; } return 0; @@ -104,7 +104,7 @@ static inline int high_timer_overflow(void) /* Check if the time elapsed in msec is sufficient to trigger an * overflow of the high precision timer */ - if (tCheck >= (k_cyc_to_ns_floor64(UINT_MAX) / + if (timestamp_check >= (k_cyc_to_ns_floor64(UINT_MAX) / (NSEC_PER_USEC * USEC_PER_MSEC))) { return -1; } diff --git a/tests/benchmarks/sys_kernel/src/syskernel.c b/tests/benchmarks/sys_kernel/src/syskernel.c index 4303e337991..3eb9dadc419 100644 --- a/tests/benchmarks/sys_kernel/src/syskernel.c +++ b/tests/benchmarks/sys_kernel/src/syskernel.c @@ -44,7 +44,7 @@ void begin_test(void) { /* * Invoke bench_test_start in order to be able to use - * tCheck static variable. + * timestamp_check static variable. */ bench_test_start(); } @@ -61,7 +61,7 @@ void begin_test(void) int check_result(int i, uint32_t t) { /* - * bench_test_end checks tCheck static variable. + * bench_test_end checks timestamp_check static variable. * bench_test_start modifies it */ if (bench_test_end() != 0) {