diff options
-rw-r--r-- | controller/fw/tools/linkmem.py | 13 |
1 files changed, 13 insertions, 0 deletions
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['<others>'] += 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): |