Handle reprojected frames in timing tools

This commit is contained in:
Patrick Nicolas
2025-02-27 10:15:03 +01:00
parent b5575528f3
commit 05fc7d57f6
+32 -12
View File
@@ -10,6 +10,7 @@ class Frame:
self.events = dict()
self.streams = dict()
self.flags = dict()
self.len = 1
def set(self, event, timestamp, stream):
if stream == 255:
@@ -17,7 +18,15 @@ class Frame:
else:
if stream not in self.streams:
self.streams[stream] = dict()
self.streams[stream][event] = timestamp
if event in ("blit", "display"):
if event not in self.streams[stream]:
self.streams[stream][event] = [timestamp]
else:
l = self.streams[stream][event]
l.append(timestamp)
self.len = max(self.len, len(l))
else:
self.streams[stream][event] = timestamp
def flag(self, stream, flag):
self.flags[stream if stream != 255 else None] = flag
@@ -59,22 +68,33 @@ def read(file: typing.TextIO) -> pandas.DataFrame:
frames[frame].flag(stream, x)
common_cols = ["wake_up", "begin", "submit"]
stream_cols = ["encode_begin", "encode_end", "send_begin", "send_end", "receive_begin", "receive_end", "decode_begin", "decode_end", "blit", "display"]
stream_cols = ["encode_begin", "encode_end", "send_begin", "send_end", "receive_begin", "receive_end", "decode_begin", "decode_end"]
display_cols = ["blit", "display"]
columns = ["frame"] + common_cols + stream_cols
columns = ["frame"] + common_cols + stream_cols + display_cols
for i in range(streams + 1):
columns += [f"{c}_{i}" for c in stream_cols]
columns += [f"{c}_{i}" for c in stream_cols + display_cols]
result = pandas.DataFrame(columns=columns)
for f in frames:
row = [f.num] + [f.events.get(c, 0) for c in common_cols]
for col in stream_cols:
op = min if col.endswith("_begin") else max
items = [s[col] for s in f.streams.values() if col in s]
row.append(op(items) if items else 0)
for j in range(f.len):
row = [f.num] + [f.events.get(c, None) for c in common_cols]
for col in stream_cols:
op = min if col.endswith("_begin") else max
items = [s[col] for s in f.streams.values() if col in s]
row.append(op(items) if items else None)
for i in range(streams + 1):
row += [f.streams.get(i, {}).get(c, 0) for c in stream_cols]
for col in display_cols:
items = [s[col][j] for s in f.streams.values() if col in s and len(s[col]) > j]
row.append(max(items) if items else None)
result.loc[len(result)] = row
for i in range(streams + 1):
stream = f.streams.get(i, {})
row += [stream.get(c, None) for c in stream_cols]
for col in display_cols:
items = stream.get(col, [])
row.append(items[j] if len(items) > j else None)
result.loc[len(result)] = row
return result