summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-07-08 23:43:32 (UTC)
committer llornkcor <llornkcor>2003-07-08 23:43:32 (UTC)
commitd94b6f057d7f4506a8b5d95a06ef36f0800e7848 (patch) (unidiff)
treecb78d50a3107b95405818f1dc17069b8232a7d84
parent86cfa9479c119d581808f53f7b46e9cfeb127ccd (diff)
downloadopie-d94b6f057d7f4506a8b5d95a06ef36f0800e7848.zip
opie-d94b6f057d7f4506a8b5d95a06ef36f0800e7848.tar.gz
opie-d94b6f057d7f4506a8b5d95a06ef36f0800e7848.tar.bz2
graphics performance test
Diffstat (more/less context) (show 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 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "performancetest.h"
22
23#include <qpe/qpeapplication.h>
24
25int main( int argc, char ** argv )
26{
27 QPEApplication a( argc, argv );
28
29 PerformanceTest mw;
30 a.showMainWidget( &mw );
31
32 return a.exec();
33}
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 @@
1Files: bin/performance apps/Applications/performance.desktop
2Priority: optional
3Section: opie/other
4Maintainer: Trolltech (www.trolltech.com)
5Architecture: $CPU_ARCH
6Arch: $DEVICE_ARCH
7Version: $QPE_VERSION-10
8Depends: qpe-libqtopia
9Description: Graphics performance tester
10 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 @@
1TEMPLATE = app
2CONFIG += qt warn_on release
3#DESTDIR = $(QPEDIR)/bin
4HEADERS = performancetest.h
5SOURCES = main.cpp performancetest.cpp
6INTERFACES = performancetestbase.ui
7TARGET = performance
8INCLUDEPATH += $(OPIEDIR)/include
9DEPENDPATH += $(OPIEDIR)/include
10LIBS += -lqpe -lqte
11
12include ( $(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 @@
1
2#include "performancetest.h"
3#include <qpe/qpeapplication.h>
4#include <qpushbutton.h>
5#include <qframe.h>
6#include <qlayout.h>
7#include <qpainter.h>
8#include <qdatetime.h>
9#include <qmultilineedit.h>
10#include <qbuttongroup.h>
11#include <qcheckbox.h>
12#include <stdlib.h>
13
14class TestItem
15{
16public:
17 TestItem( const QString &d, int it ) : msecs(0), desc(d), iter(it)
18 {
19 }
20
21 void begin()
22 {
23 timeKeeper.start();
24 }
25
26 void end()
27 {
28 msecs = timeKeeper.elapsed();
29 }
30
31 QString report() const
32 {
33 QString rpt( "%1 (%2): %3msecs" );
34 return rpt.arg(desc).arg(iter).arg(msecs);
35 }
36
37 int iterations() const { return iter; }
38 int elapsed() const { return msecs; }
39
40private:
41 int msecs;
42 QString desc;
43 int iter;
44 QTime timeKeeper;
45};
46
47void fillRect( QWidget *w, TestItem *ti )
48{
49 QPainter p( w );
50 ti->begin();
51 for ( int i = 0; i < ti->iterations(); i++ ) {
52 p.fillRect( rand() % 40, rand() % 40, 200, 200, Qt::red );
53 }
54 ti->end();
55}
56
57void bitBlt( QWidget *w, TestItem *ti )
58{
59 QPixmap pm( 200, 200 );
60 QPainter pmp( &pm );
61 pmp.setBrush( Qt::white );
62 pmp.drawRect( 0, 0, 200, 200 );
63 pmp.drawLine( 0, 0, 200, 200 );
64 pmp.drawLine( 0, 200, 200, 0 );
65 pmp.end();
66
67 QPainter p( w );
68 ti->begin();
69 for ( int i = 0; i < ti->iterations(); i++ ) {
70 p.drawPixmap( rand() % 100, rand() % 100, pm );
71 }
72 ti->end();
73}
74
75void alphaBlt( QWidget *w, TestItem *ti )
76{
77 QImage img( 200, 200, 32 );
78 img.setAlphaBuffer( TRUE );
79 for ( int y = 0; y < img.height(); y++ ) {
80 for ( int x = 0; x < img.width(); x++ ) {
81 QColor col;
82 col.setHsv( 360*x/img.width(), 255, 255 );
83 QRgb rgb = col.rgb();
84 rgb &= 0x00ffffff;
85 rgb |= (255*y/img.height()) << 24;
86 img.setPixel( x, y, rgb );
87 }
88 }
89
90 QPixmap pm;
91 pm.convertFromImage( img );
92 QPainter p( w );
93 ti->begin();
94 for ( int i = 0; i < ti->iterations(); i++ ) {
95 p.drawPixmap( rand() % 20, rand() % 20, pm );
96 }
97 ti->end();
98}
99
100void drawText( QWidget *w, TestItem *ti )
101{
102 QPainter p( w );
103 p.setPen( Qt::white );
104 QString text( "The quick red fox jumps over the lazy brown dog." ); // No tr
105 ti->begin();
106 for ( int i = 0; i < ti->iterations(); i++ ) {
107 p.drawText( rand() % 100, rand() % 300, text );
108 }
109 ti->end();
110}
111
112
113struct {
114 int id;
115 const char *name;
116 int iterations;
117 void (*testFunc)(QWidget *, TestItem *);
118}
119perfTests[] =
120{
121 { 0, "Fill Rect", 1000, &fillRect }, // No tr
122 { 1, "Bit Blt", 1000, &bitBlt }, // No tr
123 { 2, "Alpha Blt", 100, &alphaBlt }, // No tr
124 { 3, "Draw Text", 5000, &drawText }, // No tr
125 {-1, "", 0, 0 }
126};
127
128PerformanceTest::PerformanceTest( QWidget *parent, const char *name, WFlags f )
129 : PerformanceTestBase( parent, name, f )
130{
131 connect( testButton, SIGNAL(clicked()), this, SLOT(doTest()) );
132 connect( optionGroup, SIGNAL(clicked(int)), this, SLOT(testClicked(int)) );
133 QVBoxLayout *vb = new QVBoxLayout( testFrame );
134 testWidget = new QWidget( testFrame );
135 testWidget->setBackgroundColor( black );
136 vb->addWidget( testWidget );
137
138 int count = 0;
139 while ( perfTests[count].id >= 0 ) {
140 QCheckBox *cb = new QCheckBox( perfTests[count].name, optionGroup );
141 cb->setChecked( TRUE );
142 optionGroupLayout->addWidget( cb );
143 count++;
144 }
145 enabledTests.resize( count );
146 enabledTests.fill( TRUE );
147}
148
149void PerformanceTest::testClicked( int btn )
150{
151 enabledTests[btn] = optionGroup->find( btn )->isOn();
152}
153
154void PerformanceTest::doTest()
155{
156 testButton->setEnabled( FALSE );
157 qApp->processEvents();
158 int totalTime = 0;
159 int i = 0;
160 while ( perfTests[i].id >= 0 ) {
161 if ( enabledTests[i] ) {
162 srand( 1 );
163 testButton->setText( perfTests[i].name );
164 qApp->processEvents();
165 TestItem ti( perfTests[i].name, perfTests[i].iterations );
166 (perfTests[i].testFunc)(testWidget, &ti);
167 resultsEdit->append( ti.report() );
168 totalTime += ti.elapsed();
169 testWidget->erase();
170 }
171 i++;
172 }
173 resultsEdit->append( QString("-> Total time: %1ms\n").arg(totalTime) ); // No tr
174 testButton->setText( "Test" ); // No tr
175 testButton->setEnabled( TRUE );
176}
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 @@
1
2#include "performancetestbase.h"
3
4class PerformanceTest : public PerformanceTestBase
5{
6 Q_OBJECT
7public:
8 PerformanceTest( QWidget *parent=0, const char *name=0, WFlags fl=0 );
9
10protected slots:
11 void testClicked( int );
12 void doTest();
13
14private:
15 QWidget *testWidget;
16 QArray<bool> enabledTests;
17};
18
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 @@
1<!DOCTYPE UI><UI>
2<class>PerformanceTestBase</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>PerformanceTestBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>219</width>
15 <height>261</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Performance Tester</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <vbox>
26 <property stdset="1">
27 <name>margin</name>
28 <number>0</number>
29 </property>
30 <property stdset="1">
31 <name>spacing</name>
32 <number>6</number>
33 </property>
34 <widget>
35 <class>QTabWidget</class>
36 <property stdset="1">
37 <name>name</name>
38 <cstring>TabWidget2</cstring>
39 </property>
40 <property>
41 <name>layoutMargin</name>
42 </property>
43 <widget>
44 <class>QWidget</class>
45 <property stdset="1">
46 <name>name</name>
47 <cstring>tab</cstring>
48 </property>
49 <attribute>
50 <name>title</name>
51 <string>Test</string>
52 </attribute>
53 <vbox>
54 <property stdset="1">
55 <name>margin</name>
56 <number>6</number>
57 </property>
58 <property stdset="1">
59 <name>spacing</name>
60 <number>6</number>
61 </property>
62 <widget>
63 <class>QFrame</class>
64 <property stdset="1">
65 <name>name</name>
66 <cstring>testFrame</cstring>
67 </property>
68 <property stdset="1">
69 <name>frameShape</name>
70 <enum>StyledPanel</enum>
71 </property>
72 <property stdset="1">
73 <name>frameShadow</name>
74 <enum>Raised</enum>
75 </property>
76 </widget>
77 <widget>
78 <class>QPushButton</class>
79 <property stdset="1">
80 <name>name</name>
81 <cstring>testButton</cstring>
82 </property>
83 <property stdset="1">
84 <name>text</name>
85 <string>Test</string>
86 </property>
87 </widget>
88 </vbox>
89 </widget>
90 <widget>
91 <class>QWidget</class>
92 <property stdset="1">
93 <name>name</name>
94 <cstring>tab</cstring>
95 </property>
96 <attribute>
97 <name>title</name>
98 <string>Setup</string>
99 </attribute>
100 <vbox>
101 <property stdset="1">
102 <name>margin</name>
103 <number>11</number>
104 </property>
105 <property stdset="1">
106 <name>spacing</name>
107 <number>6</number>
108 </property>
109 <widget>
110 <class>QButtonGroup</class>
111 <property stdset="1">
112 <name>name</name>
113 <cstring>optionGroup</cstring>
114 </property>
115 <property stdset="1">
116 <name>title</name>
117 <string>Tests</string>
118 </property>
119 <vbox>
120 <property stdset="1">
121 <name>margin</name>
122 <number>11</number>
123 </property>
124 <property stdset="1">
125 <name>spacing</name>
126 <number>6</number>
127 </property>
128 </vbox>
129 </widget>
130 </vbox>
131 </widget>
132 <widget>
133 <class>QWidget</class>
134 <property stdset="1">
135 <name>name</name>
136 <cstring>tab</cstring>
137 </property>
138 <attribute>
139 <name>title</name>
140 <string>Results</string>
141 </attribute>
142 <vbox>
143 <property stdset="1">
144 <name>margin</name>
145 <number>6</number>
146 </property>
147 <property stdset="1">
148 <name>spacing</name>
149 <number>6</number>
150 </property>
151 <widget>
152 <class>QMultiLineEdit</class>
153 <property stdset="1">
154 <name>name</name>
155 <cstring>resultsEdit</cstring>
156 </property>
157 <property stdset="1">
158 <name>readOnly</name>
159 <bool>true</bool>
160 </property>
161 </widget>
162 </vbox>
163 </widget>
164 </widget>
165 </vbox>
166</widget>
167</UI>