From 41534d816c605d562414f67b4759d16281b609a9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Oct 2021 16:47:21 +1000 Subject: [PATCH] CPUInfo: added timing of micros16() --- Tools/CPUInfo/CPUInfo.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Tools/CPUInfo/CPUInfo.cpp b/Tools/CPUInfo/CPUInfo.cpp index e66fd277f8..8c6795eedd 100644 --- a/Tools/CPUInfo/CPUInfo.cpp +++ b/Tools/CPUInfo/CPUInfo.cpp @@ -55,13 +55,14 @@ static void show_sizes(void) #define FIFTYTIMES(x) do { TENTIMES(x); TENTIMES(x); TENTIMES(x); TENTIMES(x); TENTIMES(x); } while (0) #define TIMEIT(name, op, count) do { \ - uint32_t us_end, us_start; \ - us_start = AP_HAL::micros(); \ + uint16_t us_end, us_start; \ + us_start = AP_HAL::micros16(); \ for (uint8_t i = 0; i < count; i++) { \ FIFTYTIMES(op); \ } \ - us_end = AP_HAL::micros(); \ - hal.console->printf("%-10s %7.4f usec/call\n", name, double(us_end - us_start) / double(count * 50.0)); \ + us_end = AP_HAL::micros16(); \ + uint16_t dt_us = us_end - us_start; \ + hal.console->printf("%-10s %7.4f usec/call\n", name, double(dt_us) / double(count * 50.0)); \ hal.scheduler->delay(10); \ } while (0) @@ -101,7 +102,9 @@ static void show_timings(void) TIMEIT("nop", asm volatile("nop"::), 255); TIMEIT("micros()", AP_HAL::micros(), 200); + TIMEIT("micros16()", AP_HAL::micros16(), 200); TIMEIT("millis()", AP_HAL::millis(), 200); + TIMEIT("millis16()", AP_HAL::millis16(), 200); TIMEIT("micros64()", AP_HAL::micros64(), 200); TIMEIT("fadd", v_out += v_f, 100);