Browse Source

Improve Delay test report (#21047)

X-Ryl669 3 years ago
parent
commit
03789c4d97
No account linked to committer's email address
1 changed files with 16 additions and 14 deletions
  1. 16
    14
      Marlin/src/HAL/shared/Delay.cpp

+ 16
- 14
Marlin/src/HAL/shared/Delay.cpp View File

@@ -106,12 +106,14 @@
106 106
   }
107 107
 
108 108
   #if ENABLED(MARLIN_DEV_MODE)
109
-    void dump_delay_accuracy_check()
110
-    {
111
-      auto report_call_time = [](PGM_P const name, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
109
+    void dump_delay_accuracy_check() {
110
+      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) {
112 111
         SERIAL_ECHOPGM("Calling ");
113 112
         serialprintPGM(name);
114
-        SERIAL_ECHOLNPAIR(" for ", cycles, "cycles took: ", total, "cycles");
113
+        SERIAL_ECHOLNPAIR(" for ", cycles);
114
+        serialprintPGM(unit);
115
+        SERIAL_ECHOLNPAIR(" took: ", total);
116
+        serialprintPGM(unit);
115 117
         if (do_flush) SERIAL_FLUSH();
116 118
       };
117 119
 
@@ -123,41 +125,41 @@
123 125
       constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 };
124 126
       for (auto i : testValues) {
125 127
         s = micros(); DELAY_US(i); e = micros();
126
-        report_call_time(PSTR("delay"), i, e - s);
128
+        report_call_time(PSTR("delay"), PSTR("us"), i, e - s);
127 129
       }
128 130
 
129 131
       if (HW_REG(_DWT_CTRL)) {
130 132
         for (auto i : testValues) {
131 133
           s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT);
132
-          report_call_time(PSTR("delay"), i, e - s);
134
+          report_call_time(PSTR("runtime delay"), PSTR("cycles"), i, e - s);
133 135
         }
134 136
 
135 137
         // Measure the delay to call a real function compared to a function pointer
136 138
         s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT);
137
-        report_call_time(PSTR("delay_dwt"), 1, e - s);
139
+        report_call_time(PSTR("delay_dwt"), PSTR("cycles"), 1, e - s);
138 140
 
139 141
         static PGMSTR(dcd, "DELAY_CYCLES directly ");
140 142
 
141 143
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT);
142
-        report_call_time(dcd,  1, e - s, false);
144
+        report_call_time(dcd, PSTR("cycles"),  1, e - s, false);
143 145
 
144 146
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT);
145
-        report_call_time(dcd,  5, e - s, false);
147
+        report_call_time(dcd, PSTR("cycles"),  5, e - s, false);
146 148
 
147 149
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT);
148
-        report_call_time(dcd, 10, e - s, false);
150
+        report_call_time(dcd, PSTR("cycles"), 10, e - s, false);
149 151
 
150 152
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT);
151
-        report_call_time(dcd, 20, e - s, false);
153
+        report_call_time(dcd, PSTR("cycles"), 20, e - s, false);
152 154
 
153 155
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT);
154
-        report_call_time(dcd, 50, e - s, false);
156
+        report_call_time(dcd, PSTR("cycles"), 50, e - s, false);
155 157
 
156 158
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT);
157
-        report_call_time(dcd, 100, e - s, false);
159
+        report_call_time(dcd, PSTR("cycles"), 100, e - s, false);
158 160
 
159 161
         s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT);
160
-        report_call_time(dcd, 200, e - s, false);
162
+        report_call_time(dcd, PSTR("cycles"), 200, e - s, false);
161 163
       }
162 164
     }
163 165
   #endif // MARLIN_DEV_MODE

Loading…
Cancel
Save