godot/misc/scripts/memsort.py

36 lines
455 B
Python
Raw Normal View History

2014-02-10 09:10:30 +08:00
import sys
arg = "memdump.txt"
2014-02-10 09:10:30 +08:00
if (len(sys.argv) > 1):
arg = sys.argv[1]
2014-02-10 09:10:30 +08:00
f = open(arg, "rb")
2014-02-10 09:10:30 +08:00
l = f.readline()
2014-02-10 09:10:30 +08:00
sum = {}
cnt = {}
2014-02-10 09:10:30 +08:00
while(l != ""):
2014-02-10 09:10:30 +08:00
s = l.split("-")
amount = int(s[1])
what = s[2]
if (what in sum):
sum[what] += amount
cnt[what] += 1
else:
sum[what] = amount
cnt[what] = 1
2014-02-10 09:10:30 +08:00
l = f.readline()
2014-02-10 09:10:30 +08:00
for x in sum:
print(x.strip() + "(" + str(cnt[x]) + "):\n: " + str(sum[x]))