Skip to content

Instantly share code, notes, and snippets.

@antont
Last active April 19, 2016 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antont/54b7e68d49d807b39949ebdb830eab2c to your computer and use it in GitHub Desktop.
Save antont/54b7e68d49d807b39949ebdb830eab2c to your computer and use it in GitHub Desktop.
import json
import sys
F = sys.argv[1]
print(F)
#F = "just60.json"
#F = "c-asus_nvidia.json"
#F = TimelineRawData-20160412T120624.json"
f = open(F)
d = f.read()
j = json.loads(d)
frames = {}
fidxs = []
for l in j:
ts = int(l['ts'])
#if l['cat'] == 'toplevel':
#if l['name'] == 'GPUTask':
n = l['name']
if n == 'BeginMainThreadFrame':
fid = int(l['args']['data']['frameId'])
frames[fid] = ts
fidxs.append(fid)
fidxs.sort()
durs = []
prev_ts = -1
for fid in fidxs:
f = frames[fid]
#print(f)
if prev_ts > -1:
dur = f - prev_ts
#print(dur, fid)
if (dur > 0): #sanity filter
durs.append(dur)
#if dur < 16000:
# print(l)
prev_ts = f
print("---")
total = len(durs)
print("Frames total: %d" % total)
cats = [0, 0, 0, 0, 0]
tottime = 0
for d in durs:
if d < 17000:
catidx = 0
elif d > 200000:
catidx = 4
elif d > 100000:
catidx = 3
elif d > 33333:
catidx = 2
else:
catidx = 1
cats[catidx] += d
tottime += d
print("Total time:", tottime)
def printperc(desc, cattime):
print(desc, cattime, cattime / tottime)
printperc("~ 60 FPS:", cats[0])
printperc("30 - ~60:", cats[1])
printperc("< 30 FPS:", cats[2])
printperc("< 10 FPS:", cats[3])
printperc("< 5 FPS:", cats[4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment