From 03789c4d970c335fdeaa6cd856f36798ad015220 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Fri, 12 Feb 2021 14:49:07 +0100 Subject: [PATCH] Improve Delay test report (#21047) --- Marlin/src/HAL/shared/Delay.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Marlin/src/HAL/shared/Delay.cpp b/Marlin/src/HAL/shared/Delay.cpp index 1ae1b3e381..8ff5a88c63 100644 --- a/Marlin/src/HAL/shared/Delay.cpp +++ b/Marlin/src/HAL/shared/Delay.cpp @@ -106,12 +106,14 @@ } #if ENABLED(MARLIN_DEV_MODE) - void dump_delay_accuracy_check() - { - auto report_call_time = [](PGM_P const name, const uint32_t cycles, const uint32_t total, const bool do_flush=true) { + void dump_delay_accuracy_check() { + auto report_call_time = [](PGM_P const name, PGM_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) { SERIAL_ECHOPGM("Calling "); serialprintPGM(name); - SERIAL_ECHOLNPAIR(" for ", cycles, "cycles took: ", total, "cycles"); + SERIAL_ECHOLNPAIR(" for ", cycles); + serialprintPGM(unit); + SERIAL_ECHOLNPAIR(" took: ", total); + serialprintPGM(unit); if (do_flush) SERIAL_FLUSH(); }; @@ -123,41 +125,41 @@ constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 }; for (auto i : testValues) { s = micros(); DELAY_US(i); e = micros(); - report_call_time(PSTR("delay"), i, e - s); + report_call_time(PSTR("delay"), PSTR("us"), i, e - s); } if (HW_REG(_DWT_CTRL)) { for (auto i : testValues) { s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT); - report_call_time(PSTR("delay"), i, e - s); + report_call_time(PSTR("runtime delay"), PSTR("cycles"), i, e - s); } // Measure the delay to call a real function compared to a function pointer s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT); - report_call_time(PSTR("delay_dwt"), 1, e - s); + report_call_time(PSTR("delay_dwt"), PSTR("cycles"), 1, e - s); static PGMSTR(dcd, "DELAY_CYCLES directly "); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 1, e - s, false); + report_call_time(dcd, PSTR("cycles"), 1, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 5, e - s, false); + report_call_time(dcd, PSTR("cycles"), 5, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 10, e - s, false); + report_call_time(dcd, PSTR("cycles"), 10, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 20, e - s, false); + report_call_time(dcd, PSTR("cycles"), 20, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 50, e - s, false); + report_call_time(dcd, PSTR("cycles"), 50, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 100, e - s, false); + report_call_time(dcd, PSTR("cycles"), 100, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, 200, e - s, false); + report_call_time(dcd, PSTR("cycles"), 200, e - s, false); } } #endif // MARLIN_DEV_MODE