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 | 84 | ||||
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.h | 14 |
2 files changed, 46 insertions, 52 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 | |||
@@ -50,6 +50,9 @@ extern "C" | |||
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 |
@@ -125,7 +128,7 @@ void BenchmarkInfo::run() | |||
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 | ||
@@ -139,17 +142,15 @@ void BenchmarkInfo::run() | |||
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 | ||
@@ -190,33 +191,12 @@ void BenchmarkInfo::run() | |||
190 | } | 191 | } |
191 | 192 | ||
192 | 193 | ||
193 | void BenchmarkInfo::benchInteger() const | 194 | int BenchmarkInfo::textRendering( int seconds ) |
194 | { | ||
195 | long dummy = 1; | ||
196 | |||
197 | for ( long i= 0 ; i < INT_TEST_ITERATIONS ; i++ ) | ||
198 | { | ||
199 | for ( long j= 0 ; j < INT_TEST_ITERATIONS ; j++ ) | ||
200 | { | 195 | { |
201 | for( long k= 0 ; k < INT_TEST_ITERATIONS ; k++ ) | 196 | QTime t; |
202 | { | 197 | t.start(); |
203 | long xx = ( rand() % 1000 + 111 ) * 7 / 3 + 31; | 198 | int stop = t.elapsed() + seconds * 1000; |
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 }; |
@@ -229,16 +209,22 @@ void BenchmarkInfo::paintChar() | |||
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 }; |
@@ -251,36 +237,54 @@ void BenchmarkInfo::paintLineRect() | |||
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 ); |
266 | t.restart(); | ||
267 | stop = t.elapsed() + seconds*1000; | ||
270 | 268 | ||
271 | for ( int i = 0; i < DRAW_TEST_ITERATIONS*2; ++i ) | 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 | ||
287 | return loops; | ||
284 | 288 | ||
285 | } | 289 | } |
286 | 290 | ||
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 | |||
@@ -24,15 +24,6 @@ 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 |
@@ -61,9 +52,8 @@ public: | |||
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 | ||