From c5b4802d65d50f095a134fc8c964594219d6de62 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 28 Sep 2026 15:59:53 +0000 Subject: [PATCH] Time stamp comment: strftime costs 11.3 KB of flash and 0.8 KB of RAM here, not 5.5 KB The comment in AlexaBridgeLogic::formatTimestamp gave 5.5 KB of flash as the cost of strftime. That figure is from a build of the 1.1.0 sketch; this code base does not reproduce it. Measured on this tree, examples/basicLight.cpp for d1_mini (PlatformIO 6.2.0, espressif8266 4.2.1, Arduino core 3.1.2), static RAM / flash in bytes: as committed (gmtime_r + snprintf) 34,452 / 337,401 strftime(buffer, size, "%Y-%m-%dT%H:%M:%SZ", &utc) 35,268 / 348,701 +816 / +11,300 vsnprintf_P in place of vsnprintf in AlexaLog::write 34,460 / 343,177 +8 / +5,776 The second figure of the comment, 5.8 KB for the _P variants, is confirmed. Comment only: the build is unchanged at 34,452 / 337,401, no warnings. Co-Authored-By: Claude Fable 5.1 --- src/AlexaBridgeLogic.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/AlexaBridgeLogic.cpp b/src/AlexaBridgeLogic.cpp index 86188ed..031edf2 100644 --- a/src/AlexaBridgeLogic.cpp +++ b/src/AlexaBridgeLogic.cpp @@ -221,9 +221,10 @@ bool AlexaBridgeLogic::formatTimestamp(time_t instant, char *buffer, size_t size return false; } - // gmtime_r and snprintf instead of strftime, which links the time zone and locale tables: 5.5 KB of flash. - // snprintf and not snprintf_P: on the ESP8266 snprintf reads a PROGMEM format itself, and snprintf_P comes - // in one object with printf_P and sprintf_P, which link the FILE-based printf: 5.8 KB. + // gmtime_r and snprintf instead of strftime, which links the time zone and locale tables: 11.3 KB of flash + // and 0.8 KB of RAM. snprintf and not snprintf_P: on the ESP8266 snprintf reads a PROGMEM format itself, and + // snprintf_P comes in one object with printf_P and sprintf_P, which link the FILE-based printf: 5.8 KB of + // flash. (Both measured with examples/basicLight.cpp for d1_mini, Arduino core 3.1.2.) struct tm utc; if (gmtime_r(&instant, &utc) == nullptr) {