Add runtime_stats component for performance debugging and analysis (#9386)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
1 parent
856cb182fc
commit
e012fd5b32
10 files changed
+420
No files matched your search
@@ -9,6 +9,9 @@
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#ifdef USE_RUNTIME_STATS
|
||||
#include "esphome/components/runtime_stats/runtime_stats.h"
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
|
||||
@@ -396,6 +399,13 @@ 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
|
||||
if (global_runtime_stats != nullptr) {
|
||||
global_runtime_stats->record_component_time(this->component_, blocking_time, curr_time);
|
||||
}
|
||||
#endif
|
||||
bool should_warn;
|
||||
if (this->component_ != nullptr) {
|
||||
should_warn = this->component_->should_warn_of_blocking(blocking_time);
|
||||
|
||||
Reference in new issue
Block a user