diff --git a/dist/Plugin_sizes.txt b/dist/Plugin_sizes.txt new file mode 100644 index 000000000..4f04fbf28 --- /dev/null +++ b/dist/Plugin_sizes.txt @@ -0,0 +1,63 @@ +plugin |cache IRAM |init RAM |r.o. RAM |uninit RAM |Flash ROM +src/_C001.ino |0 |0 |272 |0 |3520 +src/_C002.ino |0 |4 |528 |32 |6064 +src/_C003.ino |0 |0 |64 |0 |1072 +src/_C004.ino |0 |0 |56 |8 |1280 +src/_C005.ino |0 |4 |56 |8 |1424 +src/_C006.ino |0 |0 |64 |0 |1296 +src/_C007.ino |0 |4 |32 |0 |1664 +src/_C008.ino |0 |0 |80 |0 |2272 +src/_C009.ino |0 |4 |352 |16 |4896 +src/_C010.ino |0 |0 |48 |0 |1136 +src/_C011.ino |0 |0 |152 |8 |5248 +src/_N001_Email.ino |0 |0 |72 |8 |1808 +src/_N002_Buzzer.ino |288 |12 |8 |264 |1184 +src/_P001_Switch.ino |1028 |8 |104 |280 |7248 +src/_P002_ADC.ino |0 |0 |16 |0 |336 +src/_P003_Pulse.ino |167 |0 |144 |192 |2544 +src/_P004_Dallas.ino |0 |0 |64 |16 |2496 +src/_P005_DHT.ino |0 |0 |56 |8 |1520 +src/_P006_BMP085.ino |0 |4 |48 |8 |2112 +src/_P007_PCF8591.ino |0 |0 |8 |8 |400 +src/_P008_RFID.ino |101 |0 |56 |8 |624 +src/_P009_MCP.ino |0 |0 |104 |24 |3232 +src/_P010_BH1750.ino |0 |0 |56 |8 |2688 +src/_P011_PME.ino |0 |4 |96 |0 |3040 +src/_P012_LCD.ino |0 |4 |120 |8 |3520 +src/_P013_HCSR04.ino |90 |0 |64 |16 |1552 +src/_P014_SI7021.ino |0 |4 |48 |0 |1824 +src/_P015_TSL2561.ino |0 |0 |56 |8 |3488 +src/_P016_IR.ino |288 |0 |72 |480 |3600 +src/_P017_PN532.ino |0 |0 |88 |72 |2016 +src/_P018_Dust.ino |0 |0 |56 |8 |512 +src/_P019_PCF8574.ino |0 |0 |104 |24 |2848 +src/_P020_Ser2Net.ino |0 |0 |88 |40 |3456 +src/_P021_Level.ino |0 |4 |136 |24 |1872 +src/_P022_PCA9685.ino |0 |4 |32 |0 |1216 +src/_P023_OLED.ino |0 |4 |80 |0 |4448 +src/_P024_MLX90614.ino |0 |4 |56 |8 |992 +src/_P025_ADS1115.ino |0 |0 |72 |8 |1184 +src/_P026_Sysinfo.ino |0 |0 |72 |8 |864 +src/_P027_INA219.ino |0 |0 |56 |24 |1840 +src/_P028_BME280.ino |128 |0 |48 |80 |3488 +src/_P029_Output.ino |0 |4 |8 |8 |256 +src/_P030_BMP280.ino |128 |0 |48 |48 |3024 +src/_P031_SHT1X.ino |0 |0 |100 |0 |2176 +src/_P032_MS5611.ino |0 |4 |88 |56 |2592 +src/_P033_Dummy.ino |0 |4 |48 |0 |1168 +src/_P034_DHT12.ino |0 |0 |16 |0 |656 +src/_P035_IRTX.ino |0 |4 |64 |-8 |3840 +src/_P036_FrameOLED.ino |0 |4 |96 |0 |33600 +src/_P037_MQTTImport.ino |0 |0 |24 |40 |3536 +src/_P038_NeoPixel.ino |128 |0 |56 |8 |1712 +src/_P039_Thermocouple.ino |0 |0 |104 |8 |1536 +src/_P040_ID12.ino |0 |4 |72 |8 |640 +src/_P041_NeoClock.ino |128 |4 |128 |0 |3344 +src/_P042_Candle.ino |128 |8 |160 |32 |8048 +src/_P043_ClkOutput.ino |0 |0 |80 |0 |1456 +src/_P044_P1WifiGateway.ino |0 |0 |80 |64 |4032 +src/_P045_MPU6050.ino |0 |4 |216 |72 |4496 +src/_P046_VentusW266.ino |325 |4 |184 |88 |3920 +src/_P047_i2c-soil-moisture-so|0 |4 |216 |8 |2144 +src/_P048_Motorshield_v2.ino |0 |32 |208 |0 |5952 +src/_P049_MHZ19.ino |380 |80 |184 |88 |3792 diff --git a/memanalyzer.py b/memanalyzer.py index d29011203..780536bca 100755 --- a/memanalyzer.py +++ b/memanalyzer.py @@ -81,69 +81,146 @@ def analyse_memory(elfFile): # print("Free IRam : %d" % usedIRAM) return(ret) -################### start -if len(sys.argv) < 1: - print("Usage: \n\t%s%s " % sys.argv[0]) - sys.exit(1) +# reenable all plugins and libs +def enable_all(): -objectDumpBin = sys.argv[1] + for plugin in glob.glob(".src/*"): + os.rename(plugin, "src/"+os.path.basename(plugin)) -#restore deleted plugins -subprocess.check_output("git ls-files -d | xargs git checkout --", shell=True) + for lib in glob.glob(".lib/*"): + os.rename(lib, "lib/"+os.path.basename(lib)) -#modified files? -if subprocess.check_output("git ls-files -m src", shell=True)!="": - abort("found modified files in src directory") +def disable_plugin(plugin): + os.rename(plugin, ".src/"+os.path.basename(plugin)) -#get list of all plugins -plugins=glob.glob("src/_[CPN]*.ino") -plugins.sort() +def enable_plugin(plugin): + os.rename(".src/"+os.path.basename(plugin), plugin) + +def disable_lib(lib): + os.rename(lib, ".lib/"+os.path.basename(lib)) + +def enable_lib(lib): + os.rename(".lib/"+os.path.basename(lib), lib) -#remove all plugins and get base size -for plugin in plugins: - os.remove(plugin) - -if len(sys.argv)>2: - test_plugins=sys.argv[2:] -else: - test_plugins=plugins - -test_plugins.sort() +try: + if not os.path.exists(".src"): + os.mkdir(".src") -output_format="{:<30}|{:<11}|{:<11}|{:<11}|{:<11}|{:<11}" -print(output_format.format( - "plugin", - "cache IRAM", - "init RAM", - "r.o. RAM", - "uninit RAM", - "Flash ROM", -)) + if not os.path.exists(".lib"): + os.mkdir(".lib") -#build without plugins to get base memory usage -subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) -#two times, sometimes it changes a few bytes somehow -subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) -base=analyse_memory(".pioenvs/dev_4096/firmware.elf") + ################### start + if len(sys.argv) < 1: + print("Usage: \n\t%s%s " % sys.argv[0]) + sys.exit(1) + + objectDumpBin = sys.argv[1] + + output_format="{:<30}|{:<11}|{:<11}|{:<11}|{:<11}|{:<11}" + print(output_format.format( + "plugin", + "cache IRAM", + "init RAM", + "r.o. RAM", + "uninit RAM", + "Flash ROM", + )) -plugin_results={} -for plugin in test_plugins: - # print("building with {}".format(plugin)) - subprocess.check_call("git checkout {}".format(plugin), shell=True) + enable_all() + + + #get list of all plugins + plugins=glob.glob("src/_[CPN]*.ino") + plugins.sort() + + #get list of all libs + libs=glob.glob("lib/*") + libs.remove("lib/pubsubclient") + libs.sort() + + + #### disable all plugins and to get base size + for plugin in plugins: + disable_plugin(plugin) + + # for lib in libs: + # disable_lib(lib) + + #build without plugins to get base memory usage subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) - plugin_results[plugin]=analyse_memory(".pioenvs/dev_4096/firmware.elf") - os.remove(plugin) + #two times, sometimes it changes a few bytes somehow + subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) + base=analyse_memory(".pioenvs/dev_4096/firmware.elf") + + + # note: unused libs never use any memory, so dont have to test this + # ##### test per lib + # results={} + # for lib in libs: + # enable_lib(lib) + # subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) + # results[lib]=analyse_memory(".pioenvs/dev_4096/firmware.elf") + # disable_lib(lib) + # + # print(output_format.format( + # lib, + # results[lib]['text']-base['text'], + # results[lib]['data']-base['data'], + # results[lib]['rodata']-base['rodata'], + # results[lib]['bss']-base['bss'], + # results[lib]['irom0_text']-base['irom0_text'], + # )) + + + #which plugins to test? + if len(sys.argv)>2: + test_plugins=sys.argv[2:] + else: + test_plugins=plugins + test_plugins.sort() + + + + ##### test per plugin + results={} + for plugin in test_plugins: + enable_plugin(plugin) + subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) + results[plugin]=analyse_memory(".pioenvs/dev_4096/firmware.elf") + disable_plugin(plugin) + + print(output_format.format( + plugin, + results[plugin]['text']-base['text'], + results[plugin]['data']-base['data'], + results[plugin]['rodata']-base['rodata'], + results[plugin]['bss']-base['bss'], + results[plugin]['irom0_text']-base['irom0_text'], + )) + + + + ##### test with all test_plugins at once + for plugin in test_plugins: + enable_plugin(plugin) + + subprocess.check_call("platformio run --silent --environment dev_4096", shell=True) + total=analyse_memory(".pioenvs/dev_4096/firmware.elf") print(output_format.format( - plugin, - plugin_results[plugin]['text']-base['text'], - plugin_results[plugin]['data']-base['data'], - plugin_results[plugin]['rodata']-base['rodata'], - plugin_results[plugin]['bss']-base['bss'], - plugin_results[plugin]['irom0_text']-base['irom0_text'], + "ALL", + total['text']-base['text'], + total['data']-base['data'], + total['rodata']-base['rodata'], + total['bss']-base['bss'], + total['irom0_text']-base['irom0_text'], )) +except: + enable_all() + + raise