-
Notifications
You must be signed in to change notification settings - Fork 1
/
score.py
executable file
·27 lines (23 loc) · 921 Bytes
/
score.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
import sys, re
if __name__ == "__main__":
src = 0
asm = 0
with open("bkgr.map", "r") as f:
content = f.read()
matches = re.findall(r'^ \.(\w+)\s+0x[0-9a-f]+\s+(0x[0-9a-f]+) (\w+)\/.+\.o', content, re.MULTILINE)
for match in matches:
if match[0] == 'text':
if match[2] == 'src':
src += int(match[1], 0)
elif match[2] == 'asm':
asm += int(match[1], 0)
elif match[0] == 'data':
if match[2] == 'src':
src += int(match[1], 0)
total = src + asm
if len(sys.argv) == 1:
print("src: {:.2f}%, 0x{:x} bytes".format(100 * src / total, src))
print("asm: {:.2f}%, 0x{:x} bytes".format(100 * asm / total, asm))
elif len(sys.argv) == 2 and sys.argv[1] == "-p":
print("{:.2f}".format(100 * src / total))