Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
benchmark.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BENCHMARK_BASELINE(scale)
 
#define BENCHMARK(msg, scale)
 
#define MEASURE(expr)   BENCHMARK(#expr,1) expr
 

Functions

void noop ()
 

Variables

static uint32_t _start
 
static uint32_t _baseline = 0
 
static uint32_t _benchmark
 

Detailed Description

Version
1.0

License

Copyright (C) 2017, Mikael Patel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Definition in file benchmark.h.

Macro Definition Documentation

#define BENCHMARK (   msg,
  scale 
)
Value:
Serial.print(F(msg ": ")); \
Serial.flush(); \
_start = micros(); \
for (int _i = 1; _i; _i--, _benchmark = micros() - _start - _baseline,\
Serial.println(_benchmark / (float) scale, 3)) \
for (int _j = scale; _j; _j--, noop())
static uint32_t _benchmark
Definition: benchmark.h:24
void noop()
Definition: benchmark.h:28
static uint32_t _start
Definition: benchmark.h:23
Software::Serial< BOARD::D0 > Serial
Definition: Benchmark.ino:5
static uint32_t _baseline
Definition: benchmark.h:23

Benchmark support macro. Use in the form:

1 BENCHMARK("description") statement

Prints description message and time to execute the statement in micro-seconds. The maximum resolution depends on micros() and is typically 4 us (F_CPU is 16 MHz). Message strings are stored in program memory.

Parameters
[in]msgdescription of the benchmark.
[in]scalenumber of block executions.

Definition at line 52 of file benchmark.h.

#define BENCHMARK_BASELINE (   scale)
Value:
Serial.flush(); \
_start = micros(); \
for (int _i = 1; _i; _i--, _baseline = micros() - _start - _baseline) \
for (int _j = scale; _j; _j--, noop())
void noop()
Definition: benchmark.h:28
static uint32_t _start
Definition: benchmark.h:23
Software::Serial< BOARD::D0 > Serial
Definition: Benchmark.ino:5
static uint32_t _baseline
Definition: benchmark.h:23

Calculate and set benchmark baseline. Should be called in setup().

Parameters
[in]scalenumber of block executions.

Definition at line 34 of file benchmark.h.

#define MEASURE (   expr)    BENCHMARK(#expr,1) expr

Execution time measurement support macro. Use in the form:

1 MEASURE(expr)

Executes given expression and prints time to execute micro- seconds. The maximum resolution depends on micros() and is typically 4 us (F_CPU is 16 MHz).

Parameters
[in]exprexpression to execute and measure.

Definition at line 70 of file benchmark.h.

Function Documentation

void noop ( )
inline

Benchmark support function.

Definition at line 28 of file benchmark.h.

Variable Documentation

uint32_t _baseline = 0
static

Definition at line 23 of file benchmark.h.

uint32_t _benchmark
static

Definition at line 24 of file benchmark.h.

uint32_t _start
static

Benchmark timestamp variables.

Definition at line 23 of file benchmark.h.