Loading...
Searching...
No Matches
benchmark.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017,2018 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
21#ifndef BENCHMARK_H
22#define BENCHMARK_H
23
24#include <stdint.h>
25
26#include "irq.h"
27#include "ztimer/stopwatch.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
44#define BENCHMARK_FUNC(name, runs, func) \
45 do { \
46 ztimer_stopwatch_t timer = { .clock = ZTIMER_USEC }; \
47 ztimer_stopwatch_start(&timer); \
48 for (unsigned long i = 0; i < runs; i++) { \
49 func; \
50 } \
51 benchmark_print_time(ztimer_stopwatch_measure(&timer), runs, name); \
52 ztimer_stopwatch_stop(&timer); \
53 } while (0)
54
62void benchmark_print_time(uint32_t time, unsigned long runs, const char *name);
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* BENCHMARK_H */
void benchmark_print_time(uint32_t time, unsigned long runs, const char *name)
Output the given time as well as the time per run on STDIO.
IRQ driver interface.