|
| espSystats () |
|
void | takeSample (const char *sampName) |
| Take a data sample immediately and memorialize it with the name passed in the argument.
|
|
void | takeSampleAndPrintResults (const char *sampName) |
| Take a sample (via takeSample()) and then print (in non-tabular form) the results.
|
|
std::string | takeSampleAndGetResults (const char *sampName) |
| Take a sample and return the results as a std::string.
|
|
void | printStaticStats () |
| Prints the non-record-based statistics only.
|
|
std::string | getStaticStats () |
| Get the non-record-based statistics only and return them in a std::string. See printStaticStats() for more detail.
|
|
void | printFullReport () |
| This is the main event for results along with getFullReport(). This prints the static stats as well as a full table of all records taken via the *Sample() functions.
|
|
std::string | getFullReport () |
| Same functionality as printFullReport() but returns the result in std::string instead of printing the results out.
|
|
Data gather and report on ESP32 system stats - mostly memory heap.
For quite a while I've used the ESP.* utility functions once in a while to print out key heap and sketch metrics when I'm scratching my head about free space and such. This class advances that notion by allowing the user to call ESPSystats.takeSample() and pass an argument which describes the point in the lifecycle in descriptive terms. These 'takeSample' items are collected by the class and are available at any time to be printed by simply calling ESPSystats.printFullReport(). The resulting output gives the user a table of memory and other stat information in chronological order from each takeSample() completed. It is a super handy way to understand what objects or portions of your code are impacting usage. An example of the output from printFullReport() follows:
ESP32 STATS: CPU Speed(MHz): 160, Sketch Size: 874400, Sketch Free Space: 436320
----------------------------------------------------------------------------
| HEAPSIZ | FREE | LARGEST | MIN | SAMPLE NAME |
----------------------------------------------------------------------------
| 312060 | 286928 | 110580 | 281356 | SETUP-pre-tft |
| 311996 | 286628 | 110580 | 281056 | SETUP-pre-lvgl |
| 310940 | 282516 | 110580 | 276908 | SETUP-post-lvgl |
| 310940 | 282412 | 110580 | 276684 | SETUP-pre-widgets |
| 310068 | 191452 | 69620 | 185880 | Splash-start |
| 306908 | 173676 | 64500 | 173580 | SETUP-end |
| 306892 | 173708 | 64500 | 171492 | Splash-end |
----------------------------------------------------------------------------
Note: Class is functional on ESP32, but on a simulated environment simply prints (via printf()) a note that such stats are unavailable.
void espSystats::printFullReport |
( |
| ) |
|
This is the main event for results along with getFullReport(). This prints the static stats as well as a full table of all records taken via the *Sample() functions.
The typical usage pattern is to utilize takeSample() from multiple places in your project - especially during startup where objects are created and graphics are set up into memory. Then, at a point when startup is relatively stable, this function is called to get a single final report to view.
This function can be called multiple times, however there is no facility to clear out prior records. Any newly taken samples will be appended to the report in subsequent calls for a full report.
A sample output report follows:
ESP32 STATS: CPU Speed(MHz): 160, Sketch Size: 874400, Sketch Free Space: 436320
----------------------------------------------------------------------------
| HEAPSIZ | FREE | LARGEST | MIN | SAMPLE NAME |
----------------------------------------------------------------------------
| 312060 | 286928 | 110580 | 281356 | SETUP-pre-tft |
| 311996 | 286628 | 110580 | 281056 | SETUP-pre-lvgl |
| 310940 | 282516 | 110580 | 276908 | SETUP-post-lvgl |
| 310940 | 282412 | 110580 | 276684 | SETUP-pre-widgets |
| 310068 | 191452 | 69620 | 185880 | Splash-start |
| 306908 | 173676 | 64500 | 173580 | SETUP-end |
| 306892 | 173708 | 64500 | 171492 | Splash-end |
----------------------------------------------------------------------------