]> git.sesse.net Git - kdenlive/commitdiff
Add an fps counter for debugging. master
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 12 Jan 2014 19:52:33 +0000 (20:52 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 13 Mar 2014 21:16:54 +0000 (22:16 +0100)
src/widgets/videoglwidget.cpp

index 3c62742e8072380fc3d820795055a7390d363a70..83aae6376e2b024b529757af43db51f78d7c6509 100644 (file)
@@ -196,6 +196,33 @@ void VideoGLWidget::showImage(const QImage &image)
 
 void VideoGLWidget::showImage(Mlt::Frame* frame, GLuint texnum)
 {
+    static bool first = true;
+    static timespec start, now;
+    static int frameno = 0;
+
+    if (first) {
+        clock_gettime(CLOCK_MONOTONIC, &start);
+        first = false;
+    }
+
+    ++frameno;
+
+    clock_gettime(CLOCK_MONOTONIC, &now);
+    double elapsed = now.tv_sec - start.tv_sec +
+        1e-9 * (now.tv_nsec - start.tv_nsec);
+    printf("%d frames in %.3f seconds = %.1f fps (%.1f ms/frame)\n",
+        frameno, elapsed, frameno / elapsed,
+        1e3 * elapsed / frameno);
+
+    // Reset every 100 frames, so that local variations in frame times
+    // (especially for the first few frames, when the shaders are
+    // compiled etc.) don't make it hard to measure for the entire
+    // remaining duration of the program.
+    if (frameno == 100) {
+        frameno = 0;
+        start = now;
+    }
+
     makeCurrent();
     GLsync sync = (GLsync) frame->get("movit.convert.fence");
     glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED);