@@ -678,6 +678,14 @@ def generate_json(self, file_desc):
678
678
file_desc .write ('\n ' )
679
679
return None
680
680
681
+ RAM_FORMAT_STR = (
682
+ "Total Static RAM memory (data + bss): {}({:+}) bytes\n "
683
+ )
684
+
685
+ ROM_FORMAT_STR = (
686
+ "Total Flash memory (text + data): {}({:+}) bytes\n "
687
+ )
688
+
681
689
def generate_csv (self , file_desc ):
682
690
"""Generate a CSV file from a memoy map
683
691
@@ -732,17 +740,22 @@ def generate_table(self, file_desc):
732
740
733
741
subtotal_row = ['Subtotals' ]
734
742
for k in self .print_sections :
735
- subtotal_row .append (self .subtotal [k ])
743
+ subtotal_row .append ("{}({:+})" .format (
744
+ self .subtotal [k ], self .subtotal [k + '-delta' ]))
736
745
737
746
table .add_row (subtotal_row )
738
747
739
748
output = table .get_string ()
740
749
output += '\n '
741
750
742
- output += "Total Static RAM memory (data + bss): %s bytes\n " % \
743
- str (self .mem_summary ['static_ram' ])
744
- output += "Total Flash memory (text + data): %s bytes\n " % \
745
- str (self .mem_summary ['total_flash' ])
751
+ output += self .RAM_FORMAT_STR .format (
752
+ self .mem_summary ['static_ram' ],
753
+ self .mem_summary ['static_ram_delta' ]
754
+ )
755
+ output += self .ROM_FORMAT_STR .format (
756
+ self .mem_summary ['total_flash' ],
757
+ self .mem_summary ['total_flash_delta' ]
758
+ )
746
759
747
760
return output
748
761
@@ -751,16 +764,24 @@ def generate_table(self, file_desc):
751
764
def compute_report (self ):
752
765
""" Generates summary of memory usage for main areas
753
766
"""
754
- for k in self .sections :
755
- self .subtotal [k ] = 0
767
+ self .subtotal = defaultdict (int )
756
768
757
769
for mod in self .modules .values ():
758
770
for k in self .sections :
759
771
self .subtotal [k ] += mod [k ]
772
+ self .subtotal [k + '-delta' ] += mod [k ]
773
+ if self .old_modules :
774
+ for mod in self .old_modules .values ():
775
+ for k in self .sections :
776
+ self .subtotal [k + '-delta' ] -= mod [k ]
760
777
761
778
self .mem_summary = {
762
- 'static_ram' : (self .subtotal ['.data' ] + self .subtotal ['.bss' ]),
779
+ 'static_ram' : self .subtotal ['.data' ] + self .subtotal ['.bss' ],
780
+ 'static_ram_delta' :
781
+ self .subtotal ['.data-delta' ] + self .subtotal ['.bss-delta' ],
763
782
'total_flash' : (self .subtotal ['.text' ] + self .subtotal ['.data' ]),
783
+ 'total_flash_delta' :
784
+ self .subtotal ['.text-delta' ] + self .subtotal ['.data-delta' ],
764
785
}
765
786
766
787
self .mem_report = []
0 commit comments