diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2010-09-08 07:17:26 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2010-09-08 07:18:50 (GMT) |
commit | 1830535a87245b611f6630dc0ce5848bfd41d075 (patch) | |
tree | 3c6ed153deb73a3e8c5887ef1f16f9d3a2015919 | |
parent | 0901337e0c23910f265f0991b9fc6875efafedaf (diff) | |
download | Qt-1830535a87245b611f6630dc0ce5848bfd41d075.zip Qt-1830535a87245b611f6630dc0ce5848bfd41d075.tar.gz Qt-1830535a87245b611f6630dc0ce5848bfd41d075.tar.bz2 |
Add average frame timing to QDeclarativeView, ifdef'ed out.
Reviewed-by: Aaron Kennedy
-rw-r--r-- | src/declarative/util/qdeclarativeview.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 8f06858..7b88610 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -702,6 +702,23 @@ void QDeclarativeView::paintEvent(QPaintEvent *event) if (frameRateDebug()) qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; + +#if QT_SHOW_DECLARATIVEVIEW_FPS + static QTime timer; + static int frames; + + if (frames == 0) { + timer.start(); + } else if (timer.elapsed() > 5000) { + qreal avgtime = timer.elapsed() / (qreal) frames; + qDebug("Average time per frame: %f ms (%i fps)", avgtime, int(1000 / avgtime)); + timer.start(); + frames = 0; + } + ++frames; + scene()->update(); +#endif + } QT_END_NAMESPACE |