summaryrefslogtreecommitdiff
path: root/development/performance
Side-by-side diff
Diffstat (limited to 'development/performance') (more/less context) (ignore whitespace changes)
-rw-r--r--development/performance/main.cpp33
-rw-r--r--development/performance/opie-performance.control10
-rw-r--r--development/performance/performance.pro12
-rw-r--r--development/performance/performancetest.cpp176
-rw-r--r--development/performance/performancetest.h18
-rw-r--r--development/performance/performancetestbase.ui167
6 files changed, 416 insertions, 0 deletions
diff --git a/development/performance/main.cpp b/development/performance/main.cpp
new file mode 100644
index 0000000..8802777
--- a/dev/null
+++ b/development/performance/main.cpp
@@ -0,0 +1,33 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "performancetest.h"
+
+#include <qpe/qpeapplication.h>
+
+int main( int argc, char ** argv )
+{
+ QPEApplication a( argc, argv );
+
+ PerformanceTest mw;
+ a.showMainWidget( &mw );
+
+ return a.exec();
+}
diff --git a/development/performance/opie-performance.control b/development/performance/opie-performance.control
new file mode 100644
index 0000000..299fda2
--- a/dev/null
+++ b/development/performance/opie-performance.control
@@ -0,0 +1,10 @@
+Files: bin/performance apps/Applications/performance.desktop
+Priority: optional
+Section: opie/other
+Maintainer: Trolltech (www.trolltech.com)
+Architecture: $CPU_ARCH
+Arch: $DEVICE_ARCH
+Version: $QPE_VERSION-10
+Depends: qpe-libqtopia
+Description: Graphics performance tester
+ Graphics performance tester for Qtopia.
diff --git a/development/performance/performance.pro b/development/performance/performance.pro
new file mode 100644
index 0000000..ab3a51a
--- a/dev/null
+++ b/development/performance/performance.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+CONFIG += qt warn_on release
+#DESTDIR = $(QPEDIR)/bin
+HEADERS = performancetest.h
+SOURCES = main.cpp performancetest.cpp
+INTERFACES = performancetestbase.ui
+TARGET = performance
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lqte
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/development/performance/performancetest.cpp b/development/performance/performancetest.cpp
new file mode 100644
index 0000000..1bc8ee0
--- a/dev/null
+++ b/development/performance/performancetest.cpp
@@ -0,0 +1,176 @@
+
+#include "performancetest.h"
+#include <qpe/qpeapplication.h>
+#include <qpushbutton.h>
+#include <qframe.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qdatetime.h>
+#include <qmultilineedit.h>
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <stdlib.h>
+
+class TestItem
+{
+public:
+ TestItem( const QString &d, int it ) : msecs(0), desc(d), iter(it)
+ {
+ }
+
+ void begin()
+ {
+ timeKeeper.start();
+ }
+
+ void end()
+ {
+ msecs = timeKeeper.elapsed();
+ }
+
+ QString report() const
+ {
+ QString rpt( "%1 (%2): %3msecs" );
+ return rpt.arg(desc).arg(iter).arg(msecs);
+ }
+
+ int iterations() const { return iter; }
+ int elapsed() const { return msecs; }
+
+private:
+ int msecs;
+ QString desc;
+ int iter;
+ QTime timeKeeper;
+};
+
+void fillRect( QWidget *w, TestItem *ti )
+{
+ QPainter p( w );
+ ti->begin();
+ for ( int i = 0; i < ti->iterations(); i++ ) {
+ p.fillRect( rand() % 40, rand() % 40, 200, 200, Qt::red );
+ }
+ ti->end();
+}
+
+void bitBlt( QWidget *w, TestItem *ti )
+{
+ QPixmap pm( 200, 200 );
+ QPainter pmp( &pm );
+ pmp.setBrush( Qt::white );
+ pmp.drawRect( 0, 0, 200, 200 );
+ pmp.drawLine( 0, 0, 200, 200 );
+ pmp.drawLine( 0, 200, 200, 0 );
+ pmp.end();
+
+ QPainter p( w );
+ ti->begin();
+ for ( int i = 0; i < ti->iterations(); i++ ) {
+ p.drawPixmap( rand() % 100, rand() % 100, pm );
+ }
+ ti->end();
+}
+
+void alphaBlt( QWidget *w, TestItem *ti )
+{
+ QImage img( 200, 200, 32 );
+ img.setAlphaBuffer( TRUE );
+ for ( int y = 0; y < img.height(); y++ ) {
+ for ( int x = 0; x < img.width(); x++ ) {
+ QColor col;
+ col.setHsv( 360*x/img.width(), 255, 255 );
+ QRgb rgb = col.rgb();
+ rgb &= 0x00ffffff;
+ rgb |= (255*y/img.height()) << 24;
+ img.setPixel( x, y, rgb );
+ }
+ }
+
+ QPixmap pm;
+ pm.convertFromImage( img );
+ QPainter p( w );
+ ti->begin();
+ for ( int i = 0; i < ti->iterations(); i++ ) {
+ p.drawPixmap( rand() % 20, rand() % 20, pm );
+ }
+ ti->end();
+}
+
+void drawText( QWidget *w, TestItem *ti )
+{
+ QPainter p( w );
+ p.setPen( Qt::white );
+ QString text( "The quick red fox jumps over the lazy brown dog." ); // No tr
+ ti->begin();
+ for ( int i = 0; i < ti->iterations(); i++ ) {
+ p.drawText( rand() % 100, rand() % 300, text );
+ }
+ ti->end();
+}
+
+
+struct {
+ int id;
+ const char *name;
+ int iterations;
+ void (*testFunc)(QWidget *, TestItem *);
+}
+perfTests[] =
+{
+ { 0, "Fill Rect", 1000, &fillRect }, // No tr
+ { 1, "Bit Blt", 1000, &bitBlt }, // No tr
+ { 2, "Alpha Blt", 100, &alphaBlt }, // No tr
+ { 3, "Draw Text", 5000, &drawText }, // No tr
+ {-1, "", 0, 0 }
+};
+
+PerformanceTest::PerformanceTest( QWidget *parent, const char *name, WFlags f )
+ : PerformanceTestBase( parent, name, f )
+{
+ connect( testButton, SIGNAL(clicked()), this, SLOT(doTest()) );
+ connect( optionGroup, SIGNAL(clicked(int)), this, SLOT(testClicked(int)) );
+ QVBoxLayout *vb = new QVBoxLayout( testFrame );
+ testWidget = new QWidget( testFrame );
+ testWidget->setBackgroundColor( black );
+ vb->addWidget( testWidget );
+
+ int count = 0;
+ while ( perfTests[count].id >= 0 ) {
+ QCheckBox *cb = new QCheckBox( perfTests[count].name, optionGroup );
+ cb->setChecked( TRUE );
+ optionGroupLayout->addWidget( cb );
+ count++;
+ }
+ enabledTests.resize( count );
+ enabledTests.fill( TRUE );
+}
+
+void PerformanceTest::testClicked( int btn )
+{
+ enabledTests[btn] = optionGroup->find( btn )->isOn();
+}
+
+void PerformanceTest::doTest()
+{
+ testButton->setEnabled( FALSE );
+ qApp->processEvents();
+ int totalTime = 0;
+ int i = 0;
+ while ( perfTests[i].id >= 0 ) {
+ if ( enabledTests[i] ) {
+ srand( 1 );
+ testButton->setText( perfTests[i].name );
+ qApp->processEvents();
+ TestItem ti( perfTests[i].name, perfTests[i].iterations );
+ (perfTests[i].testFunc)(testWidget, &ti);
+ resultsEdit->append( ti.report() );
+ totalTime += ti.elapsed();
+ testWidget->erase();
+ }
+ i++;
+ }
+ resultsEdit->append( QString("-> Total time: %1ms\n").arg(totalTime) ); // No tr
+ testButton->setText( "Test" ); // No tr
+ testButton->setEnabled( TRUE );
+}
diff --git a/development/performance/performancetest.h b/development/performance/performancetest.h
new file mode 100644
index 0000000..c0a80c4
--- a/dev/null
+++ b/development/performance/performancetest.h
@@ -0,0 +1,18 @@
+
+#include "performancetestbase.h"
+
+class PerformanceTest : public PerformanceTestBase
+{
+ Q_OBJECT
+public:
+ PerformanceTest( QWidget *parent=0, const char *name=0, WFlags fl=0 );
+
+protected slots:
+ void testClicked( int );
+ void doTest();
+
+private:
+ QWidget *testWidget;
+ QArray<bool> enabledTests;
+};
+
diff --git a/development/performance/performancetestbase.ui b/development/performance/performancetestbase.ui
new file mode 100644
index 0000000..156aa5f
--- a/dev/null
+++ b/development/performance/performancetestbase.ui
@@ -0,0 +1,167 @@
+<!DOCTYPE UI><UI>
+<class>PerformanceTestBase</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PerformanceTestBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>219</width>
+ <height>261</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Performance Tester</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QTabWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TabWidget2</cstring>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Test</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QFrame</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>testFrame</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>StyledPanel</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Raised</enum>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>testButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Test</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Setup</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QButtonGroup</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>optionGroup</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Tests</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Results</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QMultiLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>resultsEdit</cstring>
+ </property>
+ <property stdset="1">
+ <name>readOnly</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+</UI>