Benchmark

Framework for running simple runtime benchmarks. More...

Detailed Description

Framework for running simple runtime benchmarks.

Files

file  benchmark.h
 Interface for running simple benchmarks.
 

Macros

#define BENCHMARK_FUNC(name, runs, func)
 Measure the runtime of a given function call. More...
 

Functions

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. More...
 

Macro Definition Documentation

◆ BENCHMARK_FUNC

#define BENCHMARK_FUNC (   name,
  runs,
  func 
)
Value:
{ \
uint32_t _benchmark_time = xtimer_now_usec(); \
for (unsigned long i = 0; i < runs; i++) { \
func; \
} \
_benchmark_time = (xtimer_now_usec() - _benchmark_time);\
benchmark_print_time(_benchmark_time, runs, name); \
}

Measure the runtime of a given function call.

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
[in]namename for labeling the output
[in]runsnumber of times to run func
[in]funcfunction call to benchmark

Definition at line 44 of file benchmark.h.

Function Documentation

◆ 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.

Parameters
[in]timeoverall runtime in us
[in]runsnumber of runs
[in]namename to label the output
lua_riot_builtin_c::name
const char * name
Definition: lua_builtin.h:61
xtimer_now_usec
static uint32_t xtimer_now_usec(void)
get the current system time in microseconds since start