From d91c0e8bd4af917245766aa664f7039a6ce120e5 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 6 Mar 2023 14:31:09 +0100 Subject: [PATCH] sys/benchmark: make use of ztimer stopwatch --- sys/include/benchmark.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/include/benchmark.h b/sys/include/benchmark.h index 711c49ae33..e40d7fe473 100644 --- a/sys/include/benchmark.h +++ b/sys/include/benchmark.h @@ -24,7 +24,7 @@ #include #include "irq.h" -#include "ztimer.h" +#include "ztimer/stopwatch.h" #ifdef __cplusplus extern "C" { @@ -43,12 +43,13 @@ extern "C" { */ #define BENCHMARK_FUNC(name, runs, func) \ do { \ - uint32_t _benchmark_time = ztimer_now(ZTIMER_USEC); \ + ztimer_stopwatch_t timer = { .clock = ZTIMER_USEC }; \ + ztimer_stopwatch_start(&timer); \ for (unsigned long i = 0; i < runs; i++) { \ func; \ } \ - _benchmark_time = (ztimer_now(ZTIMER_USEC) - _benchmark_time);\ - benchmark_print_time(_benchmark_time, runs, name); \ + benchmark_print_time(ztimer_stopwatch_measure(&timer), runs, name); \ + ztimer_stopwatch_stop(&timer); \ } while (0) /**