From 05fc7d57f6c6737621317158e638430e75b18236 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Thu, 27 Feb 2025 10:15:03 +0100 Subject: [PATCH] Handle reprojected frames in timing tools --- tools/process_timings.py | 44 +++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/tools/process_timings.py b/tools/process_timings.py index e1a68221..9a676749 100755 --- a/tools/process_timings.py +++ b/tools/process_timings.py @@ -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