summaryrefslogtreecommitdiff
path: root/image.py
blob: 7f35ce1b46a29c8dcdf842069a78420df3c6328f (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python

import sys

def contains (str, substr):
    return str.find (substr) != -1

if len (sys.argv) < 2:
    print "usage", sys.argv[0], "<filename>"
    exit

filename = sys.argv[1]

not_in_vm_by_address = { }

area_by_reason_cached = { }
area_by_reason_uncached = { }

f = open (filename);
for line in f:
    line = line.rstrip()
    fields = line.split (',')

    if fields[0].find (']'):
        fields[0] = fields[0].partition (']')[2]

    if fields[0].find ("not backed by surface") != -1:
        tmp = fields[0].split ('-')
        why = tmp[0]
        if len (tmp) > 1:
            tmp = tmp[1].split (" ")
            address = tmp[1];
        not_in_vm_by_address[address] = why
    elif fields[0].find ("IMAGE") != -1:
        width = int (fields[1])
        height = int (fields[2])
        bpp = int (fields[3])

        in_cache = not (contains (fields[4], "non-cache"))

        if contains (fields[5], "Composite"):
            why = "Composite" + fields[6] + fields[7]
        elif contains (fields[5], "is not in video memory"):
            tmp = fields[5].split (' ')

            if tmp[2] in not_in_vm_by_address:
                why = "not in video memory:" + not_in_vm_by_address[tmp[2]]
            else:
                why = "not in video memory for unknown reason"
        elif contains (fields[5], "PutImage"):
            why = "PutImage or ShmPutImage"
        else:
            why = fields[5]

        if not why in area_by_reason_cached:
            area_by_reason_cached[why] = 0
        if not why in area_by_reason_uncached:
            area_by_reason_uncached[why] = 0

        if in_cache:
            area_by_reason_cached[why] += width * height
        else:
            area_by_reason_uncached[why] += width * height

print "=============== cached ======================"

for k in area_by_reason_cached:
    print k, area_by_reason_cached[k]

print
print "=============== uncached ===================="


for k in area_by_reason_uncached:
    print k, area_by_reason_uncached[k]