mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7377 from theotherjimmy/stats-depth-zero
Tools: Summarize stats when depth is 0pull/7421/head
commit
0ba46e74a6
|
@ -13,6 +13,7 @@ import csv
|
||||||
import json
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from collections import defaultdict
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
from jinja2 import FileSystemLoader, StrictUndefined
|
from jinja2 import FileSystemLoader, StrictUndefined
|
||||||
from jinja2.environment import Environment
|
from jinja2.environment import Environment
|
||||||
|
@ -57,7 +58,8 @@ class _Parser(object):
|
||||||
contents[section] += size
|
contents[section] += size
|
||||||
return
|
return
|
||||||
|
|
||||||
new_module = {section: size}
|
new_module = defaultdict(int)
|
||||||
|
new_module[section] = size
|
||||||
self.modules[object_name] = new_module
|
self.modules[object_name] = new_module
|
||||||
|
|
||||||
def module_replace(self, old_object, new_object):
|
def module_replace(self, old_object, new_object):
|
||||||
|
@ -506,7 +508,7 @@ class MemapParser(object):
|
||||||
if split_name[0] == '':
|
if split_name[0] == '':
|
||||||
split_name = split_name[1:]
|
split_name = split_name[1:]
|
||||||
new_name = join(*split_name[:depth])
|
new_name = join(*split_name[:depth])
|
||||||
self.short_modules.setdefault(new_name, {})
|
self.short_modules.setdefault(new_name, defaultdict(int))
|
||||||
for section_idx, value in v.items():
|
for section_idx, value in v.items():
|
||||||
self.short_modules[new_name].setdefault(section_idx, 0)
|
self.short_modules[new_name].setdefault(section_idx, 0)
|
||||||
self.short_modules[new_name][section_idx] += self.modules[module_name][section_idx]
|
self.short_modules[new_name][section_idx] += self.modules[module_name][section_idx]
|
||||||
|
@ -525,6 +527,7 @@ class MemapParser(object):
|
||||||
|
|
||||||
Returns: generated string for the 'table' format, otherwise None
|
Returns: generated string for the 'table' format, otherwise None
|
||||||
"""
|
"""
|
||||||
|
if depth is None or depth > 0:
|
||||||
self.reduce_depth(depth)
|
self.reduce_depth(depth)
|
||||||
self.compute_report()
|
self.compute_report()
|
||||||
try:
|
try:
|
||||||
|
@ -706,10 +709,9 @@ class MemapParser(object):
|
||||||
for k in self.sections:
|
for k in self.sections:
|
||||||
self.subtotal[k] = 0
|
self.subtotal[k] = 0
|
||||||
|
|
||||||
for i in self.short_modules:
|
for mod in self.modules.values():
|
||||||
for k in self.sections:
|
for k in self.sections:
|
||||||
self.short_modules[i].setdefault(k, 0)
|
self.subtotal[k] += mod[k]
|
||||||
self.subtotal[k] += self.short_modules[i][k]
|
|
||||||
|
|
||||||
self.mem_summary = {
|
self.mem_summary = {
|
||||||
'static_ram': (self.subtotal['.data'] + self.subtotal['.bss']),
|
'static_ram': (self.subtotal['.data'] + self.subtotal['.bss']),
|
||||||
|
@ -717,11 +719,12 @@ class MemapParser(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mem_report = []
|
self.mem_report = []
|
||||||
for i in sorted(self.short_modules):
|
if self.short_modules:
|
||||||
|
for name, sizes in sorted(self.short_modules.items()):
|
||||||
self.mem_report.append({
|
self.mem_report.append({
|
||||||
"module":i,
|
"module": name,
|
||||||
"size":{
|
"size":{
|
||||||
k: self.short_modules[i][k] for k in self.print_sections
|
k: sizes.get(k, 0) for k in self.print_sections
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue