#include typedef struct { unsigned sum; unsigned count; unsigned avg; } benchmark_t; static inline void start_timing() { RCC->APB1ENR |= RCC_APB1ENR_TIM7EN; TIM7->CR1 = 1; TIM7->ARR = 0xFFFF; TIM7->CNT = 0; } static inline void end_timing(benchmark_t *b) { b->sum += TIM7->CNT * 2; // APB1 prescaler = 2 b->count++; b->avg = b->sum / b->count; }