adapt new mace 0.0.14

This commit is contained in:
2025-10-12 17:09:55 +08:00
parent d9b969f644
commit 07baaae51e
9 changed files with 377 additions and 8 deletions
+1
View File
@@ -2,3 +2,4 @@
python3 -m venv .
./bin/pip3 install pandas matplotlib adjustText
rm -f .gitignore
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/python3
import sys
assert(len(sys.argv) == 2)
f = open(sys.argv[1])
lines = []
allocs = []
while True:
line = f.readline()
if len(line) < 10:
break
if line.find('INFO') != -1:
continue
pos = line.find('Status')
if pos < 0:
pos = line.find('mace')
if pos != 0:
lines.append(line[pos:])
else:
lines.append(line)
else:
cleaned = line[pos+6:].strip().strip('{}')
pairs = cleaned.split(',')
tl = [tuple(pair.split(': ')) for pair in pairs]
tl = [(k.strip(), int(v)) for k, v in tl]
allocs.append((tl, ''.join(lines)))
lines.clear()
# sort by alloc_size
allocs.sort(key=lambda x: x[0][1][1], reverse=True)
with open('alloc.txt', 'w') as o:
for x in allocs:
o.write(f'{x[0]}\n{x[1]}\n')
# sort by free_size
allocs.sort(key=lambda x: x[0][3][1], reverse=True)
with open('free.txt', 'w') as o:
for x in allocs:
o.write(f'{x[0]}\n{x[1]}\n')
alloc_size = 0
free_size = 0
for x in allocs:
alloc_size += x[0][1][1]
free_size += x[0][3][1]
print(f"total_alloc {alloc_size} total_free {free_size}")