#!/usr/bin/python import sys def contains (str, substr): return str.find (substr) != -1 if len (sys.argv) < 2: print "usage", sys.argv[0], "" 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]