"""Count draw_scene (action 9) records in a fifodump = true board fps. py fifofps.py -> total count py fifofps.py -> count now, wait, count again, report fps """ import sys, time, struct def count_frames(path): n = 0 with open(path, 'rb') as f: data = f.read() off = 0 while off + 8 <= len(data): if data[off:off+4] != b'VPXM': off += 1 continue ln = struct.unpack_from('= 4 and struct.unpack_from(' 2: secs = float(sys.argv[2]) a = count_frames(path) time.sleep(secs) b = count_frames(path) print(f"{a} -> {b} draw_scene in {secs:.0f}s = {(b-a)/secs:.1f} fps") else: print(count_frames(path), "draw_scene records")