py: db.py: Print frame rate at 5s intervals
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 2 Jan 2017 14:42:11 +0000 (16:42 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 3 Jan 2017 08:46:42 +0000 (10:46 +0200)
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 <laurent.pinchart@ideasonboard.com>
py/tests/db.py

index 20f4236..f0a962d 100755 (executable)
@@ -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: