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 "xtimer.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
44 #define BENCHMARK_FUNC(name, runs, func) \
45  { \
46  uint32_t _benchmark_time = xtimer_now_usec(); \
47  for (unsigned long i = 0; i < runs; i++) { \
48  func; \
49  } \
50  _benchmark_time = (xtimer_now_usec() - _benchmark_time);\
51  benchmark_print_time(_benchmark_time, runs, name); \
52  }
53 
61 void benchmark_print_time(uint32_t time, unsigned long runs, const char *name);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif /* BENCHMARK_H */
68 
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.
xtimer.h
xtimer interface definitions