From: Steinar H. Gunderson Date: Sun, 12 Jan 2014 19:52:33 +0000 (+0100) Subject: Add an fps counter for debugging. X-Git-Url: https://git.sesse.net/?p=kdenlive;a=commitdiff_plain;h=5521a11686dfb36d7672dd97e7d73aaef732de41 Add an fps counter for debugging. --- diff --git a/src/widgets/videoglwidget.cpp b/src/widgets/videoglwidget.cpp index 3c62742e..83aae637 100644 --- a/src/widgets/videoglwidget.cpp +++ b/src/widgets/videoglwidget.cpp @@ -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);