-
Notifications
You must be signed in to change notification settings - Fork 10
Memory space efficiency test
Michal Borowski edited this page Jun 15, 2020
·
3 revisions
25*5 array of uint32_t (500 bytes) occupies 584 bytes. So 84 bytes are dedicated for the CSV Parser class itself.
Code used:
static const char * csv_str = "442584588,965256828,948454604,1734201442,808778074\n"
"676833804,1105226709,730998146,1091610973,1679649788\n"
"812070144,1337330171,1425903881,1298078833,318796607\n"
"1934420198,161779816,1720344060,1985998041,198608100\n"
"284723106,1170242751,151376792,893107712,1158527827\n"
"442584588,965256828,948454604,1734201442,808778074\n"
"676833804,1105226709,730998146,1091610973,1679649788\n"
"812070144,1337330171,1425903881,1298078833,318796607\n"
"1934420198,161779816,1720344060,1985998041,198608100\n"
"284723106,1170242751,151376792,893107712,1158527827\n"
"442584588,965256828,948454604,1734201442,808778074\n"
"676833804,1105226709,730998146,1091610973,1679649788\n"
"812070144,1337330171,1425903881,1298078833,318796607\n"
"1934420198,161779816,1720344060,1985998041,198608100\n"
"284723106,1170242751,151376792,893107712,1158527827\n"
"442584588,965256828,948454604,1734201442,808778074\n"
"676833804,1105226709,730998146,1091610973,1679649788\n"
"812070144,1337330171,1425903881,1298078833,318796607\n"
"1934420198,161779816,1720344060,1985998041,198608100\n"
"284723106,1170242751,151376792,893107712,1158527827\n"
"442584588,965256828,948454604,1734201442,808778074\n"
"676833804,1105226709,730998146,1091610973,1679649788\n"
"812070144,1337330171,1425903881,1298078833,318796607\n"
"1934420198,161779816,1720344060,1985998041,198608100\n"
"284723106,1170242751,151376792,893107712,1158527827";
Serial.println("Free heap (before creating CSV_Parser) = " + String(ESP.getFreeHeap()));
CSV_Parser cp(csv_str, /*format*/ "LLLLL", /*has_header*/ false);
Serial.println("Free heap (after creating CSV_Parser) = " + String(ESP.getFreeHeap()));Free heap (before creating CSV_Parser) = 45888
Free heap (after creating CSV_Parser) = 45304
45888 - 45304 = 584
Existence of each column increases overhead by around 9 bytes (even if there's only 1 row). So the overhead is relatively high when large number of columns is used in CSV file.
Notice that the data in text form (excluding commas and new lines) has around 1180 characters. So using this parser (which allows to set type through "format" parameter) allows to decrease space taken by data (as compared to CSV parsers that only store data as strings).