8000 Table output for segment size script by mcspr · Pull Request #8551 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Table output for segment size script #8551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension 8000

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unicodes
  • Loading branch information
mcspr committed May 2, 2022
commit 9a399b9024b54afdd5f16eba9e1a070f4f78d0b1
36 changes: 29 additions & 7 deletions tools/sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import sys
import contextlib


HINTS = {
"ICACHE": "reserved space for flash instruction cache",
"IRAM": "code in IRAM (IRAM_ATTR, ICACHE_RAM_ATTR)",
Expand Down Expand Up @@ -88,6 +87,24 @@ def percentage(lhs, rhs):
return "{}%".format(int(100.0 * float(lhs) / float(rhs)))


def prefix(n, segments):
if n == len(segments):
out = "└──"
else:
out = "├──"

return out


def safe_prefix(n, segments):
if n == len(segments):
out = "|__"
else:
out = "|--"

return out


def main():
parser = argparse.ArgumentParser(
description="Report the different segment sizes of a compiled ELF file"
Expand Down Expand Up @@ -115,13 +132,18 @@ def main():

for group, (segments, total) in sizes:
used = sum(segments.values())
print(f". {group:<8}, total {total} bytes, used {used} bytes ({percentage(used, total)})")
print(
f". {group:<8}, total {total} bytes, used {used} bytes ({percentage(used, total)})"
)
for n, (segment, size) in enumerate(segments.items(), start=1):
if n == len(segments):
prefix = "└──"
else:
prefix = "├──"
print(f"{prefix} {segment:<8} {size:<8} {HINTS[segment]:<16}")
try:
print(
f"{prefix(n, segments)} {segment:<8} {size:<8} {HINTS[segment]:<16}"
)
except UnicodeEncodeError:
print(
f"{safe_prefix(n, segments)} {segment:<8} {size:<8} {HINTS[segment]:<16}"
)


if __name__ == "__main__":
Expand Down
0