Skip to content

Commit c2642a1

Browse files
committed
Add delta to subtotals
1 parent 0e622de commit c2642a1

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

tools/memap.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,14 @@ def generate_json(self, file_desc):
678678
file_desc.write('\n')
679679
return None
680680

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+
681689
def generate_csv(self, file_desc):
682690
"""Generate a CSV file from a memoy map
683691
@@ -732,17 +740,22 @@ def generate_table(self, file_desc):
732740

733741
subtotal_row = ['Subtotals']
734742
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']))
736745

737746
table.add_row(subtotal_row)
738747

739748
output = table.get_string()
740749
output += '\n'
741750

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+
)
746759

747760
return output
748761

@@ -751,16 +764,24 @@ def generate_table(self, file_desc):
751764
def compute_report(self):
752765
""" Generates summary of memory usage for main areas
753766
"""
754-
for k in self.sections:
755-
self.subtotal[k] = 0
767+
self.subtotal = defaultdict(int)
756768

757769
for mod in self.modules.values():
758770
for k in self.sections:
759771
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]
760777

761778
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'],
763782
'total_flash': (self.subtotal['.text'] + self.subtotal['.data']),
783+
'total_flash_delta':
784+
self.subtotal['.text-delta'] + self.subtotal['.data-delta'],
764785
}
765786

766787
self.mem_report = []

0 commit comments

Comments
 (0)