-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 | |||
@@ -52,2 +52,5 @@ extern "C" | |||
52 | 52 | ||
53 | #define DHRYSTONE_RUNS 20000000 | ||
54 | #define TEST_DURATION 3 | ||
55 | |||
53 | //=========================================================================== | 56 | //=========================================================================== |
@@ -127,3 +130,3 @@ void BenchmarkInfo::run() | |||
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 ); |
@@ -141,5 +144,4 @@ void BenchmarkInfo::run() | |||
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 ); |
@@ -149,5 +151,4 @@ void BenchmarkInfo::run() | |||
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 ); |
@@ -192,29 +193,8 @@ void BenchmarkInfo::run() | |||
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 }; |
@@ -231,12 +211,18 @@ void BenchmarkInfo::paintChar() | |||
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 | { |
@@ -253,3 +239,8 @@ void BenchmarkInfo::paintLineRect() | |||
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 | { |
@@ -258,5 +249,9 @@ void BenchmarkInfo::paintLineRect() | |||
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 | { |
@@ -265,2 +260,3 @@ void BenchmarkInfo::paintLineRect() | |||
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 | } |
@@ -269,4 +265,6 @@ void BenchmarkInfo::paintLineRect() | |||
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 | { |
@@ -275,11 +273,17 @@ void BenchmarkInfo::paintLineRect() | |||
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 | } |
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 | |||
@@ -26,11 +26,2 @@ 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 |
@@ -63,5 +54,4 @@ public: | |||
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& ); |