Skip to content

Commit 3bb66f2

Browse files
test(preview): scan recording timestamps in linear time
1 parent 877c7da commit 3bb66f2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎scripts/fixtures/issue-19442/replay.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@
3737
result["medianIntervalMs"] = statistics.median(intervals) if intervals else None
3838
result["sub33_333msIntervals"] = sum(interval < 33.333 for interval in intervals)
3939
result["sub25msIntervals"] = sum(interval < 25 for interval in intervals)
40-
result["peakFramesInSlidingSecond"] = max(
41-
(sum(start <= stamp < start + 1 for stamp in timestamps) for start in timestamps),
42-
default=0,
43-
)
40+
end = 0
41+
peak = 0
42+
for start, timestamp in enumerate(timestamps):
43+
while end < len(timestamps) and timestamps[end] < timestamp + 1:
44+
end += 1
45+
peak = max(peak, end - start)
46+
result["peakFramesInSlidingSecond"] = peak
4447
print(json.dumps(result, indent=2))

0 commit comments

Comments
 (0)