summaryrefslogtreecommitdiff
path: root/tools/scripts/memsort.py
blob: 15b4e7a84b1dfcc0471ceb18e13aa222f46557e6 (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]))