[runtime_stats] Use micros() for accurate per-component timing (#14452)

This commit is contained in:
J. Nick Koston
2026-03-04 07:17:28 -10:00
committed by GitHub
parent 37146ff565
commit 065773ed4c
4 changed files with 60 additions and 41 deletions
+5 -2
View File
@@ -529,9 +529,12 @@ uint32_t WarnIfComponentBlockingGuard::finish() {
uint32_t curr_time = millis();
uint32_t blocking_time = curr_time - this->started_;
#ifdef USE_RUNTIME_STATS
// Record component runtime stats
// Use micros() for accurate sub-millisecond timing. millis() has insufficient
// resolution — most components complete in microseconds but millis() only has
// 1ms granularity, so results were essentially random noise.
if (global_runtime_stats != nullptr) {
global_runtime_stats->record_component_time(this->component_, blocking_time, curr_time);
uint32_t duration_us = micros() - this->started_us_;
global_runtime_stats->record_component_time(this->component_, duration_us, curr_time);
}
#endif
if (blocking_time > WARN_IF_BLOCKING_OVER_MS) {