summaryrefslogtreecommitdiff
path: root/misc/scripts/memsort.py
blob: fb636b0f78e0a2273039d1e3bae403fb1e965fc0 (plain)
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
28
29
30
31
32
33
34
35

import sys

arg = "memdump.txt"

if (len(sys.argv) > 1):
    arg = sys.argv[1]

f = open(arg, "rb")


l = f.readline()


sum = {}
cnt = {}


while(l != ""):

    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

    l = f.readline()


for x in sum:
    print(x.strip() + "(" + str(cnt[x]) + "):\n: " + str(sum[x]))