Changeset 54222 in webkit


Ignore:
Timestamp:
Feb 2, 2010 3:38:21 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-02 Noam Rosenthal <noam.rosenthal@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Enable a way to measure FPS in QGVLauncher
run QGVLauncher with --show-fps to see ongoing fps measurements
This is not meant as accurate FPS, but rather as a way to find
improvements/regressions
https://bugs.webkit.org/show_bug.cgi?id=34450

  • QGVLauncher/main.cpp: (MainView::MainView): initialize FPS values (MainView::paintEvent): count a painted frame here (MainView::printFps): we print the fps with qDebug every 5 seconds.
Location:
trunk/WebKit/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/ChangeLog

    r54069 r54222  
     12010-02-02  Noam Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Enable a way to measure FPS in QGVLauncher
     6        run QGVLauncher with --show-fps to see ongoing fps measurements
     7        This is not meant as accurate FPS, but rather as a way to find
     8        improvements/regressions
     9        https://bugs.webkit.org/show_bug.cgi?id=34450
     10
     11        * QGVLauncher/main.cpp:
     12        (MainView::MainView): initialize FPS values
     13        (MainView::paintEvent): count a painted frame here
     14        (MainView::printFps): we print the fps with qDebug every 5 seconds.
     15
    1162010-01-29  Ben Murdoch  <benm@google.com>
    217
  • trunk/WebKit/qt/QGVLauncher/main.cpp

    r53698 r54222  
    126126        : QGraphicsView(parent)
    127127        , m_mainWidget(0)
     128        , m_measureFps(QApplication::instance()->arguments().contains("--show-fps"))
     129        , m_numTotalPaints(0)
     130        , m_numPaintsSinceLastMeasure(0)
    128131    {
    129132        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     
    132135        setFrameShape(QFrame::NoFrame);
    133136        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     137        if (m_measureFps) {
     138            QTimer* fpsTimer = new QTimer(this);
     139            fpsTimer->setInterval(5000);
     140            m_totalStartTime = m_startTime = QTime::currentTime();
     141            connect(fpsTimer, SIGNAL(timeout()), this, SLOT(printFps()));
     142            fpsTimer->start();
     143        }
    134144    }
    135145
     
    150160    }
    151161
     162    void paintEvent(QPaintEvent* event)
     163    {
     164        QGraphicsView::paintEvent(event);
     165        if (m_measureFps) {
     166            ++m_numPaintsSinceLastMeasure;
     167            ++m_numTotalPaints;           
     168        }
     169    }
     170
    152171    void setWaitCursor()
    153172    {
     
    196215    }
    197216
     217    void printFps()
     218    {
     219        // note that this might have a bug if you measure right around midnight, but we can live with that
     220        QTime now = QTime::currentTime();
     221        int msecs = m_startTime.msecsTo(now);
     222        int totalMsecs = m_totalStartTime.msecsTo(now);
     223        int totalFps = totalMsecs ? m_numTotalPaints * 1000 / totalMsecs : 0;
     224        int curFps = msecs ? m_numPaintsSinceLastMeasure * 1000 / msecs : 0;
     225        qDebug("[FPS] From start: %d, from last paint: %d", totalFps, curFps);
     226        m_startTime = now;
     227        m_numPaintsSinceLastMeasure = 0;
     228    }
     229
    198230signals:
    199231    void flipRequest();
     
    201233private:
    202234    QGraphicsWidget* m_mainWidget;
     235    bool m_measureFps;
     236    int m_numTotalPaints;
     237    int m_numPaintsSinceLastMeasure;
     238    QTime m_startTime;
     239    QTime m_totalStartTime;
    203240};
    204241
Note: See TracChangeset for help on using the changeset viewer.