Benchmark¶
Framework for running simple runtime benchmarks.
-
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.
Parameters
time: overall runtime in us runs: number of runs name: name to label the output
-
BENCHMARK_FUNC
( name, runs, func)¶ Measure the runtime of a given function call.
1 2 3 4 5 6 7 8 9 10
{ \ unsigned _benchmark_irqstate = irq_disable(); \ uint32_t _benchmark_time = xtimer_now_usec(); \ for (unsigned long i = 0; i < runs; i++) { \ func; \ } \ _benchmark_time = (xtimer_now_usec() - _benchmark_time);\ irq_restore(_benchmark_irqstate); \ benchmark_print_time(_benchmark_time, runs, name); \ }
As we are doing a time sensitive measurement here, there is no way around using a preprocessor function, as going with a function pointer or similar would influence the measured runtime…
Parameters
name: name for labeling the output runs: number of times to run func
func: function call to benchmark