summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/benchmarkinfo.cpp
authorzecke <zecke>2004-03-14 16:01:52 (UTC)
committer zecke <zecke>2004-03-14 16:01:52 (UTC)
commitf12af18557c8f376f0c6c30e80a85737ff6c592e (patch) (unidiff)
treed60806f34f4ff6af82491579e80c9ef72cd4071e /noncore/settings/sysinfo/benchmarkinfo.cpp
parent13aeeabab5f2a6262b33de83cc9559a49365e325 (diff)
downloadopie-f12af18557c8f376f0c6c30e80a85737ff6c592e.zip
opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.gz
opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.bz2
Make use of ODP
Diffstat (limited to 'noncore/settings/sysinfo/benchmarkinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 3c2c15f..2a52b00 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -42,25 +42,28 @@
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwhatsthis.h> 43#include <qwhatsthis.h>
44 44
45/* STD */ 45/* STD */
46#include <time.h> 46#include <time.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <math.h> 49#include <math.h>
50#if defined (__GNUC__) && (__GNUC__ < 3) 50#if defined (__GNUC__) && (__GNUC__ < 3)
51extern double round(double); 51extern double round(double);
52#endif 52#endif
53 53
54using namespace Opie::Ui;
55using namespace Opie::Core;
54extern "C" 56extern "C"
57
55{ 58{
56 void BenchFFT( void ); 59 void BenchFFT( void );
57 double dhry_main( int ); 60 double dhry_main( int );
58} 61}
59 62
60#define DHRYSTONE_RUNS 20000000 63#define DHRYSTONE_RUNS 20000000
61#define TEST_DURATION 3 64#define TEST_DURATION 3
62 65
63#define BUFF_SIZE 8192 66#define BUFF_SIZE 8192
64#define FILE_SIZE 1024 * 1024 // 1Mb 67#define FILE_SIZE 1024 * 1024 // 1Mb
65 68
66//=========================================================================== 69//===========================================================================
@@ -166,30 +169,30 @@ BenchmarkInfo::~BenchmarkInfo()
166 169
167 170
168void BenchmarkInfo::machineActivated( int index ) 171void BenchmarkInfo::machineActivated( int index )
169{ 172{
170 QStringList* results = machines[ machineCombo->text( index ) ]; 173 QStringList* results = machines[ machineCombo->text( index ) ];
171 if ( !results ) 174 if ( !results )
172 { 175 {
173 qDebug( "sysinfo: no results available." ); 176 qDebug( "sysinfo: no results available." );
174 return; 177 return;
175 } 178 }
176 QStringList::Iterator it = results->begin(); 179 QStringList::Iterator it = results->begin();
177 test_alu->setText( 2, *(it++) ); 180 test_alu->setText( 2, *(it++) );
178 test_fpu->setText( 2, *(it++) ); 181 test_fpu->setText( 2, *(it++) );
179 test_txt->setText( 2, *(it++) ); 182 test_txt->setText( 2, *(it++) );
180 test_gfx->setText( 2, *(it++) ); 183 test_gfx->setText( 2, *(it++) );
181 test_ram->setText( 2, *(it++) ); 184 test_ram->setText( 2, *(it++) );
182 test_sd->setText( 2, *(it++) ); 185 test_sd->setText( 2, *(it++) );
183 test_cf->setText( 2, *(it++) ); 186 test_cf->setText( 2, *(it++) );
184} 187}
185 188
186 189
187void BenchmarkInfo::run() 190void BenchmarkInfo::run()
188{ 191{
189 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); 192 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" );
190 qApp->processEvents(); 193 qApp->processEvents();
191 QTime t; 194 QTime t;
192 195
193 if ( test_alu->isOn() ) 196 if ( test_alu->isOn() )
194 { 197 {
195 int d = round( dhry_main( DHRYSTONE_RUNS ) ); 198 int d = round( dhry_main( DHRYSTONE_RUNS ) );
@@ -250,100 +253,100 @@ int BenchmarkInfo::textRendering( int seconds )
250 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; 253 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
251 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; 254 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
252 const QString text( "Opie Benchmark Test" ); 255 const QString text( "Opie Benchmark Test" );
253 256
254 int w = QApplication::desktop()->width(); 257 int w = QApplication::desktop()->width();
255 int h = QApplication::desktop()->height(); 258 int h = QApplication::desktop()->height();
256 259
257 srand( time( NULL ) ); 260 srand( time( NULL ) );
258 261
259 BenchmarkPaintWidget bpw; 262 BenchmarkPaintWidget bpw;
260 263
261 int loops = 0; 264 int loops = 0;
262 265
263 while ( t.elapsed() < stop ) 266 while ( t.elapsed() < stop )
264 { 267 {
265 int k = rand() % 9; 268 int k = rand() % 9;
266 int s = rand() % 100; 269 int s = rand() % 100;
267 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 270 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
268 bpw.p.setFont( QFont( "Vera", s ) ); 271 bpw.p.setFont( QFont( "Vera", s ) );
269 bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); 272 bpw.p.drawText( rand() % w, rand() % h, text, text.length() );
270 ++loops; 273 ++loops;
271 } 274 }
272 275
273 return loops * text.length(); 276 return loops * text.length();
274} 277}
275 278
276int BenchmarkInfo::gfxRendering( int seconds ) 279int BenchmarkInfo::gfxRendering( int seconds )
277{ 280{
278 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; 281 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
279 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; 282 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
280 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; 283 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
281 284
282 int w = QApplication::desktop()->width(); 285 int w = QApplication::desktop()->width();
283 int h = QApplication::desktop()->height(); 286 int h = QApplication::desktop()->height();
284 287
285 srand( time( NULL ) ); 288 srand( time( NULL ) );
286 289
287 BenchmarkPaintWidget bpw; 290 BenchmarkPaintWidget bpw;
288 291
289 QTime t; 292 QTime t;
290 t.start(); 293 t.start();
291 int stop = t.elapsed() + seconds*1000; 294 int stop = t.elapsed() + seconds*1000;
292 int loops = 0; 295 int loops = 0;
293 296
294 while ( t.elapsed() < stop ) 297 while ( t.elapsed() < stop )
295 { 298 {
296 int k = rand() % 9; 299 int k = rand() % 9;
297 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 300 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
298 bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); 301 bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h );
299 ++loops; 302 ++loops;
300 } 303 }
301 304
302 t.restart(); 305 t.restart();
303 stop = t.elapsed() + seconds*1000; 306 stop = t.elapsed() + seconds*1000;
304 307
305 while ( t.elapsed() < stop ) 308 while ( t.elapsed() < stop )
306 { 309 {
307 int k = rand() % 9; 310 int k = rand() % 9;
308 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 311 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
309 bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); 312 bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 );
310 ++loops; 313 ++loops;
311 } 314 }
312 315
313 QBrush br1; 316 QBrush br1;
314 br1.setStyle( SolidPattern ); 317 br1.setStyle( SolidPattern );
315 t.restart(); 318 t.restart();
316 stop = t.elapsed() + seconds*1000; 319 stop = t.elapsed() + seconds*1000;
317 320
318 while ( t.elapsed() < stop ) 321 while ( t.elapsed() < stop )
319 { 322 {
320 int k = rand() % 9; 323 int k = rand() % 9;
321 br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 324 br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
322 bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); 325 bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 );
323 ++loops; 326 ++loops;
324 } 327 }
325 328
326 QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); 329 QPixmap p = Resource::loadPixmap( "sysinfo/pattern" );
327 t.restart(); 330 t.restart();
328 stop = t.elapsed() + seconds*1000; 331 stop = t.elapsed() + seconds*1000;
329 332
330 while ( t.elapsed() < stop ) 333 while ( t.elapsed() < stop )
331 { 334 {
332 bpw.p.drawPixmap( rand()%w, rand()%h, p ); 335 bpw.p.drawPixmap( rand()%w, rand()%h, p );
333 ++loops; 336 ++loops;
334 } 337 }
335 338
336 return loops; 339 return loops;
337 340
338} 341}
339 342
340void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) 343void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item )
341{ 344{
342 QTime time; 345 QTime time;
343 time.start(); 346 time.start();
344 if ( writeFile( fname ) && 347 if ( writeFile( fname ) &&
345 readFile( fname ) ) 348 readFile( fname ) )
346 { 349 {
347 QFile::remove( fname ); 350 QFile::remove( fname );
348 item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); 351 item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) );
349 item->setOn( false ); 352 item->setOn( false );