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 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 15:59:53 +00:00
parent 39717d5287
commit c5b4802d65

View file

@ -221,9 +221,10 @@ bool AlexaBridgeLogic::formatTimestamp(time_t instant, char *buffer, size_t size
return false; return false;
} }
// gmtime_r and snprintf instead of strftime, which links the time zone and locale tables: 5.5 KB of flash. // gmtime_r and snprintf instead of strftime, which links the time zone and locale tables: 11.3 KB of flash
// snprintf and not snprintf_P: on the ESP8266 snprintf reads a PROGMEM format itself, and snprintf_P comes // and 0.8 KB of RAM. snprintf and not snprintf_P: on the ESP8266 snprintf reads a PROGMEM format itself, and
// in one object with printf_P and sprintf_P, which link the FILE-based printf: 5.8 KB. // 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; struct tm utc;
if (gmtime_r(&instant, &utc) == nullptr) if (gmtime_r(&instant, &utc) == nullptr)
{ {