From 9db1bfc0babb2217f2c6158e01826a7d659e9a9a Mon Sep 17 00:00:00 2001 From: Matteo Benedetto Date: Tue, 24 Mar 2026 11:56:37 +0100 Subject: [PATCH] test: fix section 6 map unpack; warmup=30; add p95 to timing stats - Section 6 _on_live_sample: buf.map() returns (ok, map_info) tuple; accessing .size on the tuple caused AttributeError for every frame (22 tracebacks in log). Fixed to unpack properly. - Section 8 WARMUP raised from 5 to 30 frames (~1.25 s) so cold-DRM DMA setup, network buffer fill, and lazy texture init all complete before stats are recorded. Eliminates the 36ms first-upload spike from post-warmup measurements. - _stat() now shows mean / p95 / max so isolated spikes are visible without inflating the headline figure. --- tests/test_video_playback_device.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_video_playback_device.py b/tests/test_video_playback_device.py index 62ba6d2..1ce7b8e 100644 --- a/tests/test_video_playback_device.py +++ b/tests/test_video_playback_device.py @@ -267,10 +267,10 @@ else: sample = sink.emit("pull-sample") if sample: buf = sample.get_buffer() - info = buf.map(Gst.MapFlags.READ) - if info.size > 0: + ok_m, map_info = buf.map(Gst.MapFlags.READ) + if ok_m and map_info.size > 0: live_frames += 1 - buf.unmap(info) + buf.unmap(map_info) return Gst.FlowReturn.OK vsink.connect("new-sample", _on_live_sample) @@ -593,7 +593,7 @@ else: print(" (close window with Escape or Q, or wait for timeout)\n") # ── SDL render loop (runs on main thread) ─────────────────────────── - WARMUP = 5 + WARMUP = 30 # skip ~1.25 s of frames to let DRM, network and texture init settle deadline8 = time.monotonic() + SDL8_SECONDS frame_n = 0 @@ -699,10 +699,13 @@ else: if not samples_us: print(f" {label:38s}: no samples") return - mn = statistics.mean(samples_us) - mx = max(samples_us) + mn = statistics.mean(samples_us) + mx = max(samples_us) pct = mn / budget * 100 - print(f" {label:38s}: mean {mn:6.0f} µs max {mx:6.0f} µs ({pct:.1f}% budget)") + # p95: sort and take the 95th-percentile value to filter outlier spikes + sorted_s = sorted(samples_us) + p95 = sorted_s[int(len(sorted_s) * 0.95)] + print(f" {label:38s}: mean {mn:6.0f} µs p95 {p95:6.0f} µs max {mx:6.0f} µs ({pct:.1f}% budget)") _stat("memmove (GStreamer thread)", fs.memmove_us[WARMUP:] if len(fs.memmove_us) > WARMUP else fs.memmove_us) _stat("SDL_UpdateNVTexture (main thread)", fs.upload_us)