Framework for running simple runtime benchmarks.  
More...
Framework for running simple runtime benchmarks. 
 | 
| file   | benchmark.h | 
|   | Interface for running simple 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.  More...
  | 
|   | 
◆ BENCHMARK_FUNC
      
        
          | #define BENCHMARK_FUNC | 
          ( | 
            | 
          name,  | 
        
        
           | 
           | 
            | 
          runs,  | 
        
        
           | 
           | 
            | 
          func  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Value:    do {                                                        \
        ztimer_stopwatch_start(&timer);                         \
        for (unsigned long i = 0; i < runs; i++) {              \
            func;                                               \
        }                                                       \
        ztimer_stopwatch_stop(&timer);                          \
    } while (0)
static uint32_t ztimer_stopwatch_measure(ztimer_stopwatch_t *timer)
Take a measurement from the stop watch timer.
 
ztimer_clock_t *const ZTIMER_USEC
Default ztimer microsecond clock.
 
 
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] | name | name for labeling the output  | 
    | [in] | runs | number of times to run func  | 
    | [in] | func | function call to benchmark  | 
  
   
Definition at line 43 of file benchmark.h.
 
 
◆ 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] | time | overall runtime in us  | 
    | [in] | runs | number of runs  | 
    | [in] | name | name to label the output  |