Added a few debug timings.

This commit is contained in:
Blaz Kristan 2023-07-05 17:16:54 +02:00
parent 45a0061660
commit ad825b80b0

View File

@ -35,12 +35,19 @@ void WLED::reset()
void WLED::loop() void WLED::loop()
{ {
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
static unsigned serviceCount = 0;
static unsigned long maxUsermodMillis = 0; static unsigned long maxUsermodMillis = 0;
static uint16_t avgUsermodMillis = 0; static size_t avgUsermodMillis = 0;
static unsigned long maxStripMillis = 0; static unsigned long maxStripMillis = 0;
static uint16_t avgStripMillis = 0; static size_t avgStripMillis = 0;
static size_t avgHandlingMillis = 0;
static size_t avgHandling2Millis = 0;
static size_t avgHandling3Millis = 0;
#endif #endif
#ifdef WLED_DEBUG
unsigned long handlingMillis = millis();
#endif
handleTime(); handleTime();
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
handleIR(); // 2nd call to function needed for ESP32 to return valid results -- should be good for ESP8266, too handleIR(); // 2nd call to function needed for ESP32 to return valid results -- should be good for ESP8266, too
@ -53,6 +60,10 @@ void WLED::loop()
#ifdef WLED_ENABLE_DMX #ifdef WLED_ENABLE_DMX
handleDMX(); handleDMX();
#endif #endif
#ifdef WLED_DEBUG
handlingMillis = millis() - handlingMillis;
avgHandlingMillis += handlingMillis;
#endif
userLoop(); userLoop();
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
@ -65,6 +76,9 @@ void WLED::loop()
if (usermodMillis > maxUsermodMillis) maxUsermodMillis = usermodMillis; if (usermodMillis > maxUsermodMillis) maxUsermodMillis = usermodMillis;
#endif #endif
#ifdef WLED_DEBUG
unsigned long handling2Millis = millis();
#endif
yield(); yield();
handleIO(); handleIO();
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
@ -73,6 +87,10 @@ void WLED::loop()
#ifndef WLED_DISABLE_ALEXA #ifndef WLED_DISABLE_ALEXA
handleAlexa(); handleAlexa();
#endif #endif
#ifdef WLED_DEBUG
handling2Millis = millis() - handling2Millis;
avgHandling2Millis += handling2Millis;
#endif
if (doCloseFile) { if (doCloseFile) {
closeFile(); closeFile();
@ -146,7 +164,7 @@ void WLED::loop()
//LED settings have been saved, re-init busses //LED settings have been saved, re-init busses
//This code block causes severe FPS drop on ESP32 with the original "if (busConfigs[0] != nullptr)" conditional. Investigate! //This code block causes severe FPS drop on ESP32 with the original "if (busConfigs[0] != nullptr)" conditional. Investigate!
if (doInitBusses) { if (busConfigs[0] != nullptr) {
doInitBusses = false; doInitBusses = false;
DEBUG_PRINTLN(F("Re-init busses.")); DEBUG_PRINTLN(F("Re-init busses."));
bool aligned = strip.checkSegmentAlignment(); //see if old segments match old bus(ses) bool aligned = strip.checkSegmentAlignment(); //see if old segments match old bus(ses)
@ -177,9 +195,16 @@ void WLED::loop()
yield(); yield();
if (doSerializeConfig) serializeConfig(); if (doSerializeConfig) serializeConfig();
#ifdef WLED_DEBUG
unsigned long handling3Millis = millis();
#endif
yield(); yield();
handleWs(); handleWs();
handleStatusLED(); handleStatusLED();
#ifdef WLED_DEBUG
handling3Millis = millis() - handling3Millis;
avgHandling3Millis += handling3Millis;
#endif
// DEBUG serial logging (every 30s) // DEBUG serial logging (every 30s)
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
@ -207,6 +232,9 @@ void WLED::loop()
DEBUG_PRINT(F("Loops/sec: ")); DEBUG_PRINTLN(loops / 30); DEBUG_PRINT(F("Loops/sec: ")); DEBUG_PRINTLN(loops / 30);
DEBUG_PRINT(F("UM time[ms]: ")); DEBUG_PRINT(avgUsermodMillis/loops); DEBUG_PRINT("/");DEBUG_PRINTLN(maxUsermodMillis); DEBUG_PRINT(F("UM time[ms]: ")); DEBUG_PRINT(avgUsermodMillis/loops); DEBUG_PRINT("/");DEBUG_PRINTLN(maxUsermodMillis);
DEBUG_PRINT(F("Strip time[ms]: ")); DEBUG_PRINT(avgStripMillis/loops); DEBUG_PRINT("/"); DEBUG_PRINTLN(maxStripMillis); DEBUG_PRINT(F("Strip time[ms]: ")); DEBUG_PRINT(avgStripMillis/loops); DEBUG_PRINT("/"); DEBUG_PRINTLN(maxStripMillis);
DEBUG_PRINT(F("Handling 1 time[ms]: ")); DEBUG_PRINTLN(avgHandlingMillis/loops);
DEBUG_PRINT(F("Handling 2 time[ms]: ")); DEBUG_PRINTLN(avgHandling2Millis/loops);
DEBUG_PRINT(F("Handling 3 time[ms]: ")); DEBUG_PRINTLN(avgHandling3Millis/loops);
} }
strip.printSize(); strip.printSize();
loops = 0; loops = 0;
@ -214,6 +242,9 @@ void WLED::loop()
maxStripMillis = 0; maxStripMillis = 0;
avgUsermodMillis = 0; avgUsermodMillis = 0;
avgStripMillis = 0; avgStripMillis = 0;
avgHandlingMillis = 0;
avgHandling2Millis = 0;
avgHandling3Millis = 0;
debugTime = millis(); debugTime = millis();
} }
loops++; loops++;