Loading...
Searching...
No Matches
benchmark.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017-2018 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include <stdint.h>
21
22#include "irq.h"
23#include "ztimer/stopwatch.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
40#define BENCHMARK_FUNC(name, runs, func) \
41 do { \
42 ztimer_stopwatch_t timer = { .clock = ZTIMER_USEC }; \
43 ztimer_stopwatch_start(&timer); \
44 for (unsigned long i = 0; i < runs; i++) { \
45 func; \
46 } \
47 benchmark_print_time(ztimer_stopwatch_measure(&timer), runs, name); \
48 ztimer_stopwatch_stop(&timer); \
49 } while (0)
50
58void benchmark_print_time(uint32_t time, unsigned long runs, const char *name);
59
60#ifdef __cplusplus
61}
62#endif
63
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.