File indexing completed on 2024-04-28 15:14:32
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 #include "MarbleTest.h" 0008 0009 #include <QCoreApplication> 0010 #include <QElapsedTimer> 0011 #include <QMessageBox> 0012 0013 #include <MarbleGlobal.h> 0014 #include <MarbleDebug.h> 0015 #include <MarbleWidget.h> 0016 #include <MarbleModel.h> 0017 0018 using namespace Marble; 0019 0020 MarbleTest::MarbleTest( MarbleWidget* marbleWidget ) 0021 : m_marbleWidget(marbleWidget) 0022 { 0023 } 0024 0025 void MarbleTest::timeDemo() 0026 { 0027 QMessageBox::information(m_marbleWidget, QString( "Marble Speed Test" ), QString( "Press Ok to start test" ) ); 0028 0029 m_marbleWidget->setViewContext( Marble::Animation ); 0030 0031 for ( int k = 0; k < 10; ++k ) { 0032 m_marbleWidget->moveRight( Instant ); 0033 QCoreApplication::flush(); 0034 m_marbleWidget->repaint(); 0035 } 0036 for ( int k = 0; k < 10; ++k ) { 0037 m_marbleWidget->moveLeft( Instant ); 0038 QCoreApplication::flush(); 0039 m_marbleWidget->repaint(); 0040 } 0041 0042 qDebug() << "Starting Performance Test"; 0043 0044 QElapsedTimer t; 0045 t.start(); 0046 0047 for ( int j = 0; j < 10; ++j ) { 0048 for ( int k = 0; k < 10; ++k ) { 0049 m_marbleWidget->moveRight( Instant ); 0050 QCoreApplication::flush(); 0051 m_marbleWidget->repaint(); 0052 } 0053 for ( int k = 0; k < 10; ++k ) { 0054 m_marbleWidget->moveLeft( Instant ); 0055 QCoreApplication::flush(); 0056 m_marbleWidget->repaint(); 0057 } 0058 } 0059 0060 qDebug( "Timedemo finished in %ims", static_cast<int>(t.elapsed())); 0061 qDebug() << QString("= %1 fps").arg(200*1000/(qreal)(t.elapsed())); 0062 0063 }