From a05c9146d46a25f95856b43c5d87620bbf19da1d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 2 Jan 2017 16:42:11 +0200 Subject: py: db.py: Print frame rate at 5s intervals Print both the number of vsyncs (as reported by the driver in flip events) and the number of flip events. This is useful to debug frame rate related issues. Signed-off-by: Laurent Pinchart --- py/tests/db.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/py/tests/db.py b/py/tests/db.py index 20f4236..f0a962d 100755 --- a/py/tests/db.py +++ b/py/tests/db.py @@ -14,8 +14,26 @@ class FlipHandler(pykms.PageFlipHandlerBase): self.front_buf = 0 self.fb1 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); self.fb2 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); + self.flips = 0 + self.frames = 0 + self.time = 0 def handle_page_flip(self, frame, time): + self.flips += 1 + if self.time == 0: + self.frames = frame + self.time = time + + time_delta = time - self.time + if time_delta >= 5: + frame_delta = frame - self.frames + print("Frame rate: %f (%u/%u frames in %f s)" % + (frame_delta / time_delta, self.flips, frame_delta, time_delta)) + + self.flips = 0 + self.frames = frame + self.time = time + if self.front_buf == 0: fb = self.fb2 else: -- cgit v1.2.3