fix: log only timings of 100ms or more by default

Every HTTP request logged two timing lines and every socket connect five,
all from the async_tcp task, at several ms each on a 115200 baud console.
Raise the default TIMING_LOG_MIN_MS to 100 and drop the unused ScopeTimer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-12 17:57:47 +02:00
parent 6cec411fa8
commit 77d3e18cce

View file

@ -4,10 +4,11 @@
#include "esp_log.h"
// Timings shorter than this are not logged. Every line costs several ms on a
// 115200 baud console so raise it (e.g. -DTIMING_LOG_MIN_MS=50) to see only
// the calls worth looking at.
// 115200 baud console, and per-request timings would add dozens of lines to
// every page load on the task that serves the sockets. Build with
// -DTIMING_LOG_MIN_MS=0 to see every timing.
#ifndef TIMING_LOG_MIN_MS
#define TIMING_LOG_MIN_MS 0
#define TIMING_LOG_MIN_MS 100
#endif
// Anything that takes at least this long is logged as a warning so the slow
// calls stand out from the routine timings.
@ -37,14 +38,4 @@ static inline void logElapsed(const char *tag, const char *what, uint32_t us) {
static inline void logIfSlow(const char *tag, const char *what, uint32_t us, uint32_t minMs) {
if(us >= minMs * 1000) logElapsed(tag, what, us);
}
// Logs the time the enclosing scope took when it ends.
class ScopeTimer {
const char *_tag;
const char *_what;
ElapsedTimer _timer;
public:
ScopeTimer(const char *tag, const char *what) : _tag(tag), _what(what) {}
~ScopeTimer() { logElapsed(_tag, _what, _timer.us()); }
};
#endif