From 838eb6b26e4acc53cda47abaca6ed6392ae31ffc Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 13 Mar 2020 13:52:00 +0100 Subject: linkmem: add subdir size contribution calculation --- controller/fw/tools/linkmem.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'controller/fw') diff --git a/controller/fw/tools/linkmem.py b/controller/fw/tools/linkmem.py index 4cfceb5..db8ddb8 100644 --- a/controller/fw/tools/linkmem.py +++ b/controller/fw/tools/linkmem.py @@ -169,6 +169,19 @@ if __name__ == '__main__': subdir_colors = sorted({ first_comp(obj[len(subdir_prefix):]) for obj in obj_size if obj.startswith(subdir_prefix) }) subdir_colors = { path: hexcolor(*matplotlib.cm.Pastel1(i/len(subdir_colors))) for i, path in enumerate(subdir_colors) } + subdir_sizes = defaultdict(lambda: 0) + for obj, size in obj_size.items(): + if not isinstance(size, int): + continue + if obj.startswith(subdir_prefix): + subdir_sizes[first_comp(obj[len(subdir_prefix):])] += size + else: + subdir_sizes[''] += size + + print('Subdir sizes:', file=sys.stderr) + for subdir, size in sorted(subdir_sizes.items(), key=lambda x: x[1]): + print(f'{subdir:>20}: {size:>6,d} B', file=sys.stderr) + def lookup_highlight(path): if args.highlight_subdirs: if obj.startswith(subdir_prefix): -- cgit