mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
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:
parent
6cec411fa8
commit
77d3e18cce
1 changed files with 4 additions and 13 deletions
17
src/Timing.h
17
src/Timing.h
|
|
@ -4,10 +4,11 @@
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
// Timings shorter than this are not logged. Every line costs several ms on a
|
// 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
|
// 115200 baud console, and per-request timings would add dozens of lines to
|
||||||
// the calls worth looking at.
|
// 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
|
#ifndef TIMING_LOG_MIN_MS
|
||||||
#define TIMING_LOG_MIN_MS 0
|
#define TIMING_LOG_MIN_MS 100
|
||||||
#endif
|
#endif
|
||||||
// Anything that takes at least this long is logged as a warning so the slow
|
// Anything that takes at least this long is logged as a warning so the slow
|
||||||
// calls stand out from the routine timings.
|
// 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) {
|
static inline void logIfSlow(const char *tag, const char *what, uint32_t us, uint32_t minMs) {
|
||||||
if(us >= minMs * 1000) logElapsed(tag, what, us);
|
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
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue