Merge branch 'app-loop-optimize-speed' into integration

This commit is contained in:
J. Nick Koston
2026-04-12 20:31:23 -10:00
5 changed files with 12 additions and 5 deletions
+2 -1
View File
@@ -84,7 +84,8 @@ static StaticTask_t loop_task_tcb; // NOLINT(cppcoreguidelines-avoid-non-
static StackType_t
loop_task_stack[ESPHOME_LOOP_TASK_STACK_SIZE]; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
void __attribute__((optimize("O2"))) loop_task(void *pv_params) {
void __attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)
loop_task(void *pv_params) {
setup();
while (true) {
App.loop();
+2 -1
View File
@@ -77,7 +77,8 @@ uint32_t arch_get_cpu_freq_hz() { return 1000000000U; }
void setup();
void loop();
int main() {
int __attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)
main() {
// Install signal handlers for graceful shutdown (flushes preferences to disk)
std::signal(SIGINT, signal_handler);
std::signal(SIGTERM, signal_handler);
+2 -1
View File
@@ -95,7 +95,8 @@ void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parame
void setup();
void loop();
int main() {
int __attribute__((optimize("O2"))) // NOLINT(clang-diagnostic-unknown-attributes)
main() {
setup();
while (true) {
loop();
+4 -1
View File
@@ -569,7 +569,10 @@ inline void ESPHOME_ALWAYS_INLINE Application::before_loop_tasks_(uint32_t loop_
this->in_loop_ = true;
}
inline void ESPHOME_ALWAYS_INLINE Application::loop() {
// NOLINTNEXTLINE(clang-diagnostic-unknown-attributes)
inline void ESPHOME_ALWAYS_INLINE __attribute__((optimize("O2"))) Application::loop() {
uint8_t new_app_state = 0;
// Get the initial loop time at the start
uint32_t last_op_end_time = millis();
+2 -1
View File
@@ -783,7 +783,8 @@ def test_write_cpp_creates_new_file(
assert CPP_AUTO_GENERATE_END in written_content
assert test_code in written_content
assert "void setup()" in written_content
assert "void loop()" in written_content
assert 'optimize("O2")' in written_content
assert "loop()" in written_content
assert "App.setup();" in written_content
assert "App.loop();" in written_content