Skip to content

Commit 49834ae

Browse files
Wrap debug messages with a conditional compilation check. (#23)
1 parent 44fca49 commit 49834ae

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pxtextension.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ namespace mlrunner {
7373

7474
void runModel() {
7575
if (!initialised) return;
76-
unsigned int time_start = uBit.systemTime();
76+
#if ML_DEBUG_PRINT
77+
const unsigned int time_start = system_timer_current_time_us();
78+
#endif
7779

7880
float *modelData = mlDataProcessor.getProcessedData();
7981
if (modelData == NULL) {
@@ -88,7 +90,8 @@ namespace mlrunner {
8890
uBit.panic(MlRunnerError::ErrorModelInference);
8991
}
9092

91-
DEBUG_PRINT("P (%d ms): ", uBit.systemTime() - time_start);
93+
#if ML_DEBUG_PRINT
94+
DEBUG_PRINT("P (%d us): ", system_timer_current_time_us() - time_start);
9295
if (predictions->index >= 0) {
9396
DEBUG_PRINT_RAW("%d %s\t\t",
9497
predictions->index,
@@ -101,7 +104,8 @@ namespace mlrunner {
101104
actions->action[i].label,
102105
(int)(predictions->prediction[i] * 100));
103106
}
104-
DEBUG_PRINT_RAW("\n\n");
107+
DEBUG_PRINT_RAW("\n");
108+
#endif
105109

106110
// Model prediction events start after the None event ID
107111
uint16_t predictionEventId = predictions->index + ML_EVENT_NONE_ID + 1;

0 commit comments

Comments
 (0)