Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
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
20
#include <stdint.h>
21
22
#include "
irq.h
"
23
#include "ztimer/stopwatch.h"
24
25
#ifdef __cplusplus
26
extern
"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
58
void
benchmark_print_time
(uint32_t time,
unsigned
long
runs,
const
char
*name);
59
60
#ifdef __cplusplus
61
}
62
#endif
63
benchmark_print_time
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.h
IRQ driver interface.
Generated on Mon Nov 24 2025 18:43:15 by
1.9.1