aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-10-11 11:10:41 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-11 14:21:53 +0200
commitf41753f034343ef5c2daaa27a2b0961b98bef151 (patch)
treeed7a8f885ca2afde5667923728f4b584baf69de0
parent483b85ab599d5cee7614a84b6c73e275076bd52f (diff)
More accurate timing for rendering thread
To get a better overview of how much time we consumed rendering each frame, setting QElapsedTimer around each loop in the rendering thread. It can be turned on with QML_CANVAS_TIMING=1 environment variable. Change-Id: I81a231983e5f7d898589d5fe18782dd5c7e8e0dc Reviewed-on: http://codereview.qt-project.org/6420 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
-rw-r--r--src/declarative/items/qsgcanvas.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp
index 09a13f403c..9efd17ae11 100644
--- a/src/declarative/items/qsgcanvas.cpp
+++ b/src/declarative/items/qsgcanvas.cpp
@@ -64,6 +64,15 @@
QT_BEGIN_NAMESPACE
+#define QSG_CANVAS_TIMING
+#ifdef QSG_CANVAS_TIMING
+static bool qsg_canvas_timing = !qgetenv("QML_CANVAS_TIMING").isEmpty();
+static QTime threadTimer;
+static int syncTime;
+static int renderTime;
+static int swapTime;
+#endif
+
DEFINE_BOOL_CONFIG_OPTION(qmlFixedAnimationStep, QML_FIXED_ANIMATION_STEP)
DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP)
@@ -1943,7 +1952,6 @@ void QSGCanvasRenderLoop::createGLContext()
gl->create();
}
-
void QSGCanvasRenderThread::run()
{
#ifdef THREAD_DEBUG
@@ -1995,6 +2003,10 @@ void QSGCanvasRenderThread::run()
#ifdef THREAD_DEBUG
printf(" RenderThread: Doing locked sync\n");
#endif
+#ifdef QSG_CANVAS_TIMING
+ if (qsg_canvas_timing)
+ threadTimer.start();
+#endif
inSync = true;
syncSceneGraph();
inSync = false;
@@ -2006,14 +2018,20 @@ void QSGCanvasRenderThread::run()
#ifdef THREAD_DEBUG
printf(" RenderThread: sync done\n");
#endif
-
-
+#ifdef QSG_CANVAS_TIMING
+ if (qsg_canvas_timing)
+ syncTime = threadTimer.elapsed();
+#endif
#ifdef THREAD_DEBUG
printf(" RenderThread: rendering... %d x %d\n", windowSize.width(), windowSize.height());
#endif
renderSceneGraph(windowSize);
+#ifdef QSG_CANVAS_TIMING
+ if (qsg_canvas_timing)
+ renderTime = threadTimer.elapsed() - syncTime;
+#endif
// The content of the target buffer is undefined after swap() so grab needs
// to happen before swap();
@@ -2033,6 +2051,14 @@ void QSGCanvasRenderThread::run()
#ifdef THREAD_DEBUG
printf(" RenderThread: swap complete...\n");
#endif
+#ifdef QSG_CANVAS_TIMING
+ if (qsg_canvas_timing) {
+ swapTime = threadTimer.elapsed() - renderTime;
+ qDebug() << "- Breakdown of frame time: sync:" << syncTime
+ << "ms render:" << renderTime << "ms swap:" << swapTime
+ << "ms total:" << swapTime + renderTime << "ms";
+ }
+#endif
lock();
isPaintCompleted = true;