author | mickeyl <mickeyl> | 2004-02-27 21:02:29 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-27 21:02:29 (UTC) |
commit | a7f2e72eeb595c8f68d5af963ed6e00a4c3a4fe3 (patch) (unidiff) | |
tree | 8b30c59362edb898e425ef7d6f9ee717d20c3e1e | |
parent | a43a2e70536e9a47c0fee542c2c1ad5cc027fff4 (diff) | |
download | opie-a7f2e72eeb595c8f68d5af963ed6e00a4c3a4fe3.zip opie-a7f2e72eeb595c8f68d5af963ed6e00a4c3a4fe3.tar.gz opie-a7f2e72eeb595c8f68d5af963ed6e00a4c3a4fe3.tar.bz2 |
convert text and gfx tests to using a fixed time of seconds. that makes
results more comparable between a broad range of machines
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.h | 14 |
2 files changed, 48 insertions, 54 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 1d0b140..3dd4121 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -1,380 +1,384 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** BenchmarkInfo | 2 | ** BenchmarkInfo |
3 | ** | 3 | ** |
4 | ** A benchmark for Qt/Embedded | 4 | ** A benchmark for Qt/Embedded |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> | 6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> |
7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> | 7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> |
8 | ** | 8 | ** |
9 | ** This file may be distributed and/or modified under the terms of the | 9 | ** This file may be distributed and/or modified under the terms of the |
10 | ** GNU General Public License version 2 as published by the Free Software | 10 | ** GNU General Public License version 2 as published by the Free Software |
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | 11 | ** Foundation and appearing in the file LICENSE.GPL included in the |
12 | ** packaging of this file. | 12 | ** packaging of this file. |
13 | ** | 13 | ** |
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
16 | ** | 16 | ** |
17 | **********************************************************************/ | 17 | **********************************************************************/ |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpedecoration_qws.h> | 22 | #include <qpe/qpedecoration_qws.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qfiledialog.h> | 28 | #include <qfiledialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpainter.h> | 30 | #include <qpainter.h> |
31 | #include <qdirectpainter_qws.h> | 31 | #include <qdirectpainter_qws.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qclipboard.h> | 34 | #include <qclipboard.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qcolor.h> | 36 | #include <qcolor.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | 38 | ||
39 | /* STD */ | 39 | /* STD */ |
40 | #include <time.h> | 40 | #include <time.h> |
41 | #include <stdio.h> | 41 | #include <stdio.h> |
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <math.h> | 43 | #include <math.h> |
44 | 44 | ||
45 | #include "benchmarkinfo.h" | 45 | #include "benchmarkinfo.h" |
46 | 46 | ||
47 | extern "C" | 47 | extern "C" |
48 | { | 48 | { |
49 | void BenchFFT( void ); | 49 | void BenchFFT( void ); |
50 | double dhry_main( int ); | 50 | double dhry_main( int ); |
51 | } | 51 | } |
52 | 52 | ||
53 | #define DHRYSTONE_RUNS 20000000 | ||
54 | #define TEST_DURATION 3 | ||
55 | |||
53 | //=========================================================================== | 56 | //=========================================================================== |
54 | 57 | ||
55 | class BenchmarkPaintWidget : public QWidget | 58 | class BenchmarkPaintWidget : public QWidget |
56 | { | 59 | { |
57 | public: | 60 | public: |
58 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 61 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
59 | { | 62 | { |
60 | resize( QApplication::desktop()->size() ); | 63 | resize( QApplication::desktop()->size() ); |
61 | show(); | 64 | show(); |
62 | p.begin( this ); | 65 | p.begin( this ); |
63 | }; | 66 | }; |
64 | 67 | ||
65 | ~BenchmarkPaintWidget() | 68 | ~BenchmarkPaintWidget() |
66 | { | 69 | { |
67 | p.end(); | 70 | p.end(); |
68 | hide(); | 71 | hide(); |
69 | }; | 72 | }; |
70 | 73 | ||
71 | QPainter p; | 74 | QPainter p; |
72 | }; | 75 | }; |
73 | 76 | ||
74 | //=========================================================================== | 77 | //=========================================================================== |
75 | 78 | ||
76 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 79 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
77 | : QWidget( parent, name, wFlags ) | 80 | : QWidget( parent, name, wFlags ) |
78 | { | 81 | { |
79 | 82 | ||
80 | setMinimumSize( 200, 150 ); | 83 | setMinimumSize( 200, 150 ); |
81 | 84 | ||
82 | QVBoxLayout* vb = new QVBoxLayout( this ); | 85 | QVBoxLayout* vb = new QVBoxLayout( this ); |
83 | vb->setSpacing( 4 ); | 86 | vb->setSpacing( 4 ); |
84 | vb->setMargin( 4 ); | 87 | vb->setMargin( 4 ); |
85 | 88 | ||
86 | tests = new QListView( this ); | 89 | tests = new QListView( this ); |
87 | tests->setMargin( 1 ); | 90 | tests->setMargin( 1 ); |
88 | tests->addColumn( "Tests" ); | 91 | tests->addColumn( "Tests" ); |
89 | tests->addColumn( "Results" ); | 92 | tests->addColumn( "Results" ); |
90 | tests->setShowSortIndicator( true ); | 93 | tests->setShowSortIndicator( true ); |
91 | 94 | ||
92 | test_alu = new QCheckListItem( tests, "1: Integer Arithmetic ", QCheckListItem::CheckBox ); | 95 | test_alu = new QCheckListItem( tests, "1: Integer Arithmetic ", QCheckListItem::CheckBox ); |
93 | test_alu->setText( 1, "n/a" ); | 96 | test_alu->setText( 1, "n/a" ); |
94 | test_fpu = new QCheckListItem( tests, "2: Floating Point Unit ", QCheckListItem::CheckBox ); | 97 | test_fpu = new QCheckListItem( tests, "2: Floating Point Unit ", QCheckListItem::CheckBox ); |
95 | test_fpu->setText( 1, "n/a" ); | 98 | test_fpu->setText( 1, "n/a" ); |
96 | test_txt = new QCheckListItem( tests, "3: Text Rendering ", QCheckListItem::CheckBox ); | 99 | test_txt = new QCheckListItem( tests, "3: Text Rendering ", QCheckListItem::CheckBox ); |
97 | test_txt->setText( 1, "n/a" ); | 100 | test_txt->setText( 1, "n/a" ); |
98 | test_gfx = new QCheckListItem( tests, "4: Gfx Rendering ", QCheckListItem::CheckBox ); | 101 | test_gfx = new QCheckListItem( tests, "4: Gfx Rendering ", QCheckListItem::CheckBox ); |
99 | test_gfx->setText( 1, "n/a" ); | 102 | test_gfx->setText( 1, "n/a" ); |
100 | test_ram = new QCheckListItem( tests, "5: RAM Performance ", QCheckListItem::CheckBox ); | 103 | test_ram = new QCheckListItem( tests, "5: RAM Performance ", QCheckListItem::CheckBox ); |
101 | test_ram->setText( 1, "n/a" ); | 104 | test_ram->setText( 1, "n/a" ); |
102 | test_sd = new QCheckListItem( tests, "6: SD Card Performance ", QCheckListItem::CheckBox ); | 105 | test_sd = new QCheckListItem( tests, "6: SD Card Performance ", QCheckListItem::CheckBox ); |
103 | test_sd->setText( 1, "n/a" ); | 106 | test_sd->setText( 1, "n/a" ); |
104 | test_cf = new QCheckListItem( tests, "7: CF Card Performance ", QCheckListItem::CheckBox ); | 107 | test_cf = new QCheckListItem( tests, "7: CF Card Performance ", QCheckListItem::CheckBox ); |
105 | test_cf->setText( 1, "n/a" ); | 108 | test_cf->setText( 1, "n/a" ); |
106 | 109 | ||
107 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 110 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
108 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 111 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
109 | 112 | ||
110 | vb->addWidget( tests, 2 ); | 113 | vb->addWidget( tests, 2 ); |
111 | vb->addWidget( startButton ); | 114 | vb->addWidget( startButton ); |
112 | } | 115 | } |
113 | 116 | ||
114 | 117 | ||
115 | BenchmarkInfo::~BenchmarkInfo() | 118 | BenchmarkInfo::~BenchmarkInfo() |
116 | {} | 119 | {} |
117 | 120 | ||
118 | 121 | ||
119 | void BenchmarkInfo::run() | 122 | void BenchmarkInfo::run() |
120 | { | 123 | { |
121 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 124 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
122 | qApp->processEvents(); | 125 | qApp->processEvents(); |
123 | QTime t; | 126 | QTime t; |
124 | 127 | ||
125 | if ( test_alu->isOn() ) | 128 | if ( test_alu->isOn() ) |
126 | { | 129 | { |
127 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 130 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
128 | test_alu->setText( 1, QString( "%1 DHRYS" ).arg( QString::number( d ) ) ); | 131 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
129 | test_alu->setOn( false ); | 132 | test_alu->setOn( false ); |
130 | } | 133 | } |
131 | 134 | ||
132 | if ( test_fpu->isOn() ) | 135 | if ( test_fpu->isOn() ) |
133 | { | 136 | { |
134 | t.start(); | 137 | t.start(); |
135 | BenchFFT(); | 138 | BenchFFT(); |
136 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 139 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
137 | test_fpu->setOn( false ); | 140 | test_fpu->setOn( false ); |
138 | } | 141 | } |
139 | 142 | ||
140 | if ( test_txt->isOn() ) | 143 | if ( test_txt->isOn() ) |
141 | { | 144 | { |
142 | t.start(); | 145 | int value = textRendering( TEST_DURATION ); |
143 | paintChar(); | 146 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
144 | test_txt->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | ||
145 | test_txt->setOn( false ); | 147 | test_txt->setOn( false ); |
146 | } | 148 | } |
147 | 149 | ||
148 | if ( test_gfx->isOn() ) | 150 | if ( test_gfx->isOn() ) |
149 | { | 151 | { |
150 | t.start(); | 152 | int value = gfxRendering( TEST_DURATION ); |
151 | paintLineRect(); | 153 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
152 | test_gfx->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | ||
153 | test_gfx->setOn( false ); | 154 | test_gfx->setOn( false ); |
154 | } | 155 | } |
155 | 156 | ||
156 | if ( test_ram->isOn() ) | 157 | if ( test_ram->isOn() ) |
157 | { | 158 | { |
158 | t.start(); | 159 | t.start(); |
159 | writeFile( "/tmp/benchmarkFile.dat" ); // /tmp is supposed to be in RAM on a PDA | 160 | writeFile( "/tmp/benchmarkFile.dat" ); // /tmp is supposed to be in RAM on a PDA |
160 | readFile( "/tmp/benchmarkFile.dat" ); | 161 | readFile( "/tmp/benchmarkFile.dat" ); |
161 | QFile::remove( "/tmp/benchmarkFile.dat" ); | 162 | QFile::remove( "/tmp/benchmarkFile.dat" ); |
162 | test_ram->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 163 | test_ram->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
163 | test_ram->setOn( false ); | 164 | test_ram->setOn( false ); |
164 | } | 165 | } |
165 | /* | 166 | /* |
166 | if ( test_cf->isOn() ) | 167 | if ( test_cf->isOn() ) |
167 | { | 168 | { |
168 | t.start(); | 169 | t.start(); |
169 | benchInteger(); | 170 | benchInteger(); |
170 | test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 171 | test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
171 | test_alu->setOn( false ); | 172 | test_alu->setOn( false ); |
172 | } | 173 | } |
173 | 174 | ||
174 | if ( test_sd->isOn() ) | 175 | if ( test_sd->isOn() ) |
175 | { | 176 | { |
176 | t.start(); | 177 | t.start(); |
177 | benchInteger(); | 178 | benchInteger(); |
178 | test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 179 | test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
179 | test_alu->setOn( false ); | 180 | test_alu->setOn( false ); |
180 | } | 181 | } |
181 | 182 | ||
182 | if ( ( which_clipb ) && ( buf.length() > 0 ) ) | 183 | if ( ( which_clipb ) && ( buf.length() > 0 ) ) |
183 | { | 184 | { |
184 | clb = QApplication::clipboard(); | 185 | clb = QApplication::clipboard(); |
185 | clb->setText( dt_buf + buf ); | 186 | clb->setText( dt_buf + buf ); |
186 | } | 187 | } |
187 | */ | 188 | */ |
188 | 189 | ||
189 | startButton->setText( tr( "&Start Tests!" ) ); | 190 | startButton->setText( tr( "&Start Tests!" ) ); |
190 | } | 191 | } |
191 | 192 | ||
192 | 193 | ||
193 | void BenchmarkInfo::benchInteger() const | 194 | int BenchmarkInfo::textRendering( int seconds ) |
194 | { | 195 | { |
195 | long dummy = 1; | 196 | QTime t; |
196 | 197 | t.start(); | |
197 | for ( long i= 0 ; i < INT_TEST_ITERATIONS ; i++ ) | 198 | int stop = t.elapsed() + seconds * 1000; |
198 | { | ||
199 | for ( long j= 0 ; j < INT_TEST_ITERATIONS ; j++ ) | ||
200 | { | ||
201 | for( long k= 0 ; k < INT_TEST_ITERATIONS ; k++ ) | ||
202 | { | ||
203 | long xx = ( rand() % 1000 + 111 ) * 7 / 3 + 31; | ||
204 | long yy = ( rand() % 100 + 23 ) * 11 / 7 + 17; | ||
205 | long zz = ( rand() % 100 + 47 ) * 13 / 11 - 211; | ||
206 | dummy = xx * yy / zz; | ||
207 | dummy *= 23; | ||
208 | dummy += ( xx - yy + zz ); | ||
209 | dummy -= ( xx + yy - zz ); | ||
210 | dummy *= ( xx * zz * yy ); | ||
211 | dummy /= 1 + ( xx * yy * zz ); | ||
212 | } | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | |||
217 | 199 | ||
218 | void BenchmarkInfo::paintChar() | ||
219 | { | ||
220 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 200 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
221 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 201 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
222 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 202 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
223 | const QString text( "Opie Benchmark Test" ); | 203 | const QString text( "Opie Benchmark Test" ); |
224 | 204 | ||
225 | int w = QApplication::desktop()->width(); | 205 | int w = QApplication::desktop()->width(); |
226 | int h = QApplication::desktop()->height(); | 206 | int h = QApplication::desktop()->height(); |
227 | 207 | ||
228 | srand( time( NULL ) ); | 208 | srand( time( NULL ) ); |
229 | 209 | ||
230 | BenchmarkPaintWidget bpw; | 210 | BenchmarkPaintWidget bpw; |
231 | 211 | ||
232 | for ( int i = 0; i < CHAR_TEST_ITERATIONS; ++i ) | 212 | int loops = 0; |
213 | |||
214 | while ( t.elapsed() < stop ) | ||
233 | { | 215 | { |
234 | int k = rand() % 9; | 216 | int k = rand() % 9; |
217 | int s = rand() % 100; | ||
235 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 218 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
236 | bpw.p.setFont( QFont( "Vera", k*10 ) ); | 219 | bpw.p.setFont( QFont( "Vera", s ) ); |
237 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 220 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
221 | ++loops; | ||
238 | } | 222 | } |
223 | |||
224 | return loops * text.length(); | ||
239 | } | 225 | } |
240 | 226 | ||
241 | void BenchmarkInfo::paintLineRect() | 227 | int BenchmarkInfo::gfxRendering( int seconds ) |
242 | { | 228 | { |
243 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 229 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
244 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 230 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
245 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 231 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
246 | 232 | ||
247 | int w = QApplication::desktop()->width(); | 233 | int w = QApplication::desktop()->width(); |
248 | int h = QApplication::desktop()->height(); | 234 | int h = QApplication::desktop()->height(); |
249 | 235 | ||
250 | srand( time( NULL ) ); | 236 | srand( time( NULL ) ); |
251 | 237 | ||
252 | BenchmarkPaintWidget bpw; | 238 | BenchmarkPaintWidget bpw; |
253 | 239 | ||
254 | for ( int i = 0; i < DRAW_TEST_ITERATIONS*3; ++i ) | 240 | QTime t; |
241 | t.start(); | ||
242 | int stop = t.elapsed() + seconds*1000; | ||
243 | int loops = 0; | ||
244 | |||
245 | while ( t.elapsed() < stop ) | ||
255 | { | 246 | { |
256 | int k = rand() % 9; | 247 | int k = rand() % 9; |
257 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 248 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
258 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 249 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
250 | ++loops; | ||
259 | } | 251 | } |
260 | 252 | ||
261 | for ( int i = 0; i < DRAW_TEST_ITERATIONS; ++i ) | 253 | t.restart(); |
254 | stop = t.elapsed() + seconds*1000; | ||
255 | |||
256 | while ( t.elapsed() < stop ) | ||
262 | { | 257 | { |
263 | int k = rand() % 9; | 258 | int k = rand() % 9; |
264 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 259 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
265 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 260 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
261 | ++loops; | ||
266 | } | 262 | } |
267 | 263 | ||
268 | QBrush br1; | 264 | QBrush br1; |
269 | br1.setStyle( SolidPattern ); | 265 | br1.setStyle( SolidPattern ); |
270 | 266 | t.restart(); | |
271 | for ( int i = 0; i < DRAW_TEST_ITERATIONS*2; ++i ) | 267 | stop = t.elapsed() + seconds*1000; |
268 | |||
269 | while ( t.elapsed() < stop ) | ||
272 | { | 270 | { |
273 | int k = rand() % 9; | 271 | int k = rand() % 9; |
274 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 272 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
275 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 273 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
274 | ++loops; | ||
276 | } | 275 | } |
277 | 276 | ||
278 | QPixmap p = Resource::loadPixmap( "pattern" ); | 277 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
279 | for ( int i = 0; i < DRAW_TEST_ITERATIONS; ++i ) | 278 | t.restart(); |
279 | stop = t.elapsed() + seconds*1000; | ||
280 | |||
281 | while ( t.elapsed() < stop ) | ||
280 | { | 282 | { |
281 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 283 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
284 | ++loops; | ||
282 | } | 285 | } |
283 | 286 | ||
284 | 287 | return loops; | |
288 | |||
285 | } | 289 | } |
286 | 290 | ||
287 | // ********************************************************************** | 291 | // ********************************************************************** |
288 | // Read & Write | 292 | // Read & Write |
289 | // v2.0.0 | 293 | // v2.0.0 |
290 | // ********************************************************************** | 294 | // ********************************************************************** |
291 | #define BUFF_SIZE 8192 | 295 | #define BUFF_SIZE 8192 |
292 | #define FILE_SIZE 1024 * 1024 // 1Mb | 296 | #define FILE_SIZE 1024 * 1024 // 1Mb |
293 | 297 | ||
294 | char FileBuf[ BUFF_SIZE + 1 ]; | 298 | char FileBuf[ BUFF_SIZE + 1 ]; |
295 | 299 | ||
296 | bool BenchmarkInfo::writeFile( const QString& w_path ) | 300 | bool BenchmarkInfo::writeFile( const QString& w_path ) |
297 | { | 301 | { |
298 | int i; | 302 | int i; |
299 | int k; | 303 | int k; |
300 | int n; | 304 | int n; |
301 | int pos; | 305 | int pos; |
302 | int len; | 306 | int len; |
303 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 | 307 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 |
304 | 308 | ||
305 | 309 | ||
306 | // /*------------------------------------ | 310 | // /*------------------------------------ |
307 | int w_len; | 311 | int w_len; |
308 | 312 | ||
309 | QFile writeFile( w_path ); | 313 | QFile writeFile( w_path ); |
310 | srand( time( NULL ) ); | 314 | srand( time( NULL ) ); |
311 | 315 | ||
312 | for ( n = 0 ; n < 20 ; n++ ) | 316 | for ( n = 0 ; n < 20 ; n++ ) |
313 | { | 317 | { |
314 | if ( ! writeFile.open( IO_WriteOnly ) ) | 318 | if ( ! writeFile.open( IO_WriteOnly ) ) |
315 | { | 319 | { |
316 | writeFile.close(); | 320 | writeFile.close(); |
317 | writeFile.remove(); | 321 | writeFile.remove(); |
318 | return ( false ); | 322 | return ( false ); |
319 | } | 323 | } |
320 | // ------------------------------------------ sequential write | 324 | // ------------------------------------------ sequential write |
321 | for ( k = 0 ; k < 256 ; k++ ) | 325 | for ( k = 0 ; k < 256 ; k++ ) |
322 | { | 326 | { |
323 | n = rand() % 30; | 327 | n = rand() % 30; |
324 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); | 328 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); |
325 | } | 329 | } |
326 | 330 | ||
327 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 331 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
328 | { | 332 | { |
329 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); | 333 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); |
330 | if ( w_len != BUFF_SIZE ) | 334 | if ( w_len != BUFF_SIZE ) |
331 | { | 335 | { |
332 | writeFile.close(); | 336 | writeFile.close(); |
333 | writeFile.remove(); | 337 | writeFile.remove(); |
334 | return ( false ); | 338 | return ( false ); |
335 | } | 339 | } |
336 | writeFile.flush(); | 340 | writeFile.flush(); |
337 | } | 341 | } |
338 | // ------------------------------------------ random write | 342 | // ------------------------------------------ random write |
339 | for ( i = 0 ; i < 400 ; i++ ) | 343 | for ( i = 0 ; i < 400 ; i++ ) |
340 | { | 344 | { |
341 | len = rand() % 90 + 4000; | 345 | len = rand() % 90 + 4000; |
342 | for ( k = 0 ; k < 128 ; k++ ) | 346 | for ( k = 0 ; k < 128 ; k++ ) |
343 | { | 347 | { |
344 | n = rand() % 30; | 348 | n = rand() % 30; |
345 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); | 349 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); |
346 | } | 350 | } |
347 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); | 351 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); |
348 | 352 | ||
349 | writeFile.at( pos ); | 353 | writeFile.at( pos ); |
350 | w_len = writeFile.writeBlock( FileBuf, len ); | 354 | w_len = writeFile.writeBlock( FileBuf, len ); |
351 | if ( w_len != len ) | 355 | if ( w_len != len ) |
352 | { | 356 | { |
353 | writeFile.close(); | 357 | writeFile.close(); |
354 | writeFile.remove(); | 358 | writeFile.remove(); |
355 | return ( false ); | 359 | return ( false ); |
356 | } | 360 | } |
357 | writeFile.flush(); | 361 | writeFile.flush(); |
358 | } | 362 | } |
359 | writeFile.close(); | 363 | writeFile.close(); |
360 | } | 364 | } |
361 | return ( true ); | 365 | return ( true ); |
362 | // ------------------------------------*/ | 366 | // ------------------------------------*/ |
363 | 367 | ||
364 | /* ---------------------------------- | 368 | /* ---------------------------------- |
365 | srand( time( NULL ) ); | 369 | srand( time( NULL ) ); |
366 | 370 | ||
367 | FILE *fp; | 371 | FILE *fp; |
368 | 372 | ||
369 | for( n= 0 ; n < 40 ; n++ ) | 373 | for( n= 0 ; n < 40 ; n++ ) |
370 | { | 374 | { |
371 | if (( fp = fopen( w_path, "wt" )) == NULL ) | 375 | if (( fp = fopen( w_path, "wt" )) == NULL ) |
372 | return( false ); | 376 | return( false ); |
373 | memset( FileBuf, '\0', BUFF_SIZE+1 ); | 377 | memset( FileBuf, '\0', BUFF_SIZE+1 ); |
374 | // ------------------------------------------ sequential write | 378 | // ------------------------------------------ sequential write |
375 | for( i= 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 379 | for( i= 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
376 | { | 380 | { |
377 | for( k= 0 ; k < 128 ; k++ ) | 381 | for( k= 0 ; k < 128 ; k++ ) |
378 | { | 382 | { |
379 | n = rand() % 30; | 383 | n = rand() % 30; |
380 | memcpy( &FileBuf[k*8], &data[n], 32 ); | 384 | memcpy( &FileBuf[k*8], &data[n], 32 ); |
diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h index 2d994b4..55398eb 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.h +++ b/noncore/settings/sysinfo/benchmarkinfo.h | |||
@@ -1,73 +1,63 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** BenchmarkInfo | 2 | ** BenchmarkInfo |
3 | ** | 3 | ** |
4 | ** A benchmark for Qt/Embedded | 4 | ** A benchmark for Qt/Embedded |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> | 6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> |
7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> | 7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> |
8 | ** | 8 | ** |
9 | ** This file may be distributed and/or modified under the terms of the | 9 | ** This file may be distributed and/or modified under the terms of the |
10 | ** GNU General Public License version 2 as published by the Free Software | 10 | ** GNU General Public License version 2 as published by the Free Software |
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | 11 | ** Foundation and appearing in the file LICENSE.GPL included in the |
12 | ** packaging of this file. | 12 | ** packaging of this file. |
13 | ** | 13 | ** |
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
16 | ** | 16 | ** |
17 | **********************************************************************/ | 17 | **********************************************************************/ |
18 | 18 | ||
19 | #include <qwidget.h> | 19 | #include <qwidget.h> |
20 | #include <qdialog.h> | 20 | #include <qdialog.h> |
21 | 21 | ||
22 | class QClipboard; | 22 | class QClipboard; |
23 | class QCheckListItem; | 23 | class QCheckListItem; |
24 | class QPushButton; | 24 | class QPushButton; |
25 | class QListView; | 25 | class QListView; |
26 | 26 | ||
27 | //#define INT_TEST_ITERATIONS 50 | ||
28 | //#define CHAR_TEST_ITERATIONS 15000 | ||
29 | //#define DRAW_TEST_ITERATIONS 5000 | ||
30 | |||
31 | #define INT_TEST_ITERATIONS 50 | ||
32 | #define DHRYSTONE_RUNS 20000000 | ||
33 | #define CHAR_TEST_ITERATIONS 15000 | ||
34 | #define DRAW_TEST_ITERATIONS 5000 | ||
35 | |||
36 | class BenchmarkInfo : public QWidget | 27 | class BenchmarkInfo : public QWidget |
37 | { | 28 | { |
38 | Q_OBJECT | 29 | Q_OBJECT |
39 | 30 | ||
40 | public: | 31 | public: |
41 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); | 32 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); |
42 | ~BenchmarkInfo(); | 33 | ~BenchmarkInfo(); |
43 | 34 | ||
44 | QCheckListItem* test_alu; | 35 | QCheckListItem* test_alu; |
45 | QCheckListItem* test_fpu; | 36 | QCheckListItem* test_fpu; |
46 | QCheckListItem* test_txt; | 37 | QCheckListItem* test_txt; |
47 | QCheckListItem* test_gfx; | 38 | QCheckListItem* test_gfx; |
48 | QCheckListItem* test_ram; | 39 | QCheckListItem* test_ram; |
49 | QCheckListItem* test_sd; | 40 | QCheckListItem* test_sd; |
50 | QCheckListItem* test_cf; | 41 | QCheckListItem* test_cf; |
51 | 42 | ||
52 | bool main_rd; | 43 | bool main_rd; |
53 | bool main_wt; | 44 | bool main_wt; |
54 | bool sd_rd; | 45 | bool sd_rd; |
55 | bool sd_wt; | 46 | bool sd_wt; |
56 | bool cf_rd; | 47 | bool cf_rd; |
57 | bool cf_wt; | 48 | bool cf_wt; |
58 | 49 | ||
59 | QClipboard* clb; | 50 | QClipboard* clb; |
60 | 51 | ||
61 | QListView* tests; | 52 | QListView* tests; |
62 | QPushButton* startButton; | 53 | QPushButton* startButton; |
63 | 54 | ||
64 | void benchInteger() const; | 55 | int textRendering( int ); |
65 | void paintChar(); | 56 | int gfxRendering( int ); |
66 | void paintLineRect(); | ||
67 | bool writeFile( const QString& ); | 57 | bool writeFile( const QString& ); |
68 | bool readFile( const QString& ); | 58 | bool readFile( const QString& ); |
69 | 59 | ||
70 | private slots: | 60 | private slots: |
71 | void run(); | 61 | void run(); |
72 | 62 | ||
73 | }; | 63 | }; |