sys/benchmark: remove BENCHMARK_SETUP()

This commit is contained in:
Kaspar Schleiser 2018-02-19 22:46:25 +01:00
parent 26ad044e12
commit 5efd9599e0
2 changed files with 11 additions and 19 deletions

View File

@ -29,13 +29,6 @@
extern "C" { extern "C" {
#endif #endif
/**
* @brief Prepare the current scope for running BENCHMARK_x() macros
*/
#define BENCHMARK_SETUP() \
unsigned state; \
unsigned time
/** /**
* @brief Measure the runtime of a given function call * @brief Measure the runtime of a given function call
* *
@ -43,21 +36,21 @@ extern "C" {
* using a preprocessor function, as going with a function pointer or similar * using a preprocessor function, as going with a function pointer or similar
* would influence the measured runtime... * would influence the measured runtime...
* *
* @note BENCHMARK_SETUP() needs to be called in the same scope
*
* @param[in] name name for labeling the output * @param[in] name name for labeling the output
* @param[in] runs number of times to run @p func * @param[in] runs number of times to run @p func
* @param[in] func function call to benchmark * @param[in] func function call to benchmark
*/ */
#define BENCHMARK_FUNC(name, runs, func) \ #define BENCHMARK_FUNC(name, runs, func) \
state = irq_disable(); \ { \
time = xtimer_now_usec(); \ unsigned _benchmark_irqstate = irq_disable(); \
for (unsigned long i = 0; i < runs; i++) { \ uint32_t _benchmark_time = xtimer_now_usec(); \
func; \ for (unsigned long i = 0; i < runs; i++) { \
} \ func; \
time = (xtimer_now_usec() - time); \ } \
irq_restore(state); \ _benchmark_time = (xtimer_now_usec() - _benchmark_time);\
benchmark_print_time(time, runs, name) irq_restore(_benchmark_irqstate); \
benchmark_print_time(_benchmark_time, runs, name); \
}
/** /**
* @brief Output the given time as well as the time per run on STDIO * @brief Output the given time as well as the time per run on STDIO

View File

@ -221,7 +221,6 @@ static int bench(int argc, char **argv)
} }
puts("\nGPIO driver run-time performance benchmark\n"); puts("\nGPIO driver run-time performance benchmark\n");
BENCHMARK_SETUP();
BENCHMARK_FUNC("nop loop", runs, __asm__ volatile("nop")); BENCHMARK_FUNC("nop loop", runs, __asm__ volatile("nop"));
BENCHMARK_FUNC("gpio_set", runs, gpio_set(pin)); BENCHMARK_FUNC("gpio_set", runs, gpio_set(pin));
BENCHMARK_FUNC("gpio_clear", runs, gpio_clear(pin)); BENCHMARK_FUNC("gpio_clear", runs, gpio_clear(pin));