summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-08-19 13:57:02 (UTC)
committer mickeyl <mickeyl>2004-08-19 13:57:02 (UTC)
commitc028ea76557f18eda9d26ee46a48f461504f3ad2 (patch) (unidiff)
tree36e406a19b71dd075768c9299104482cb4ab8796
parent64bf315f998ef3ce0114adffa95fafaf2482ee17 (diff)
downloadopie-c028ea76557f18eda9d26ee46a48f461504f3ad2.zip
opie-c028ea76557f18eda9d26ee46a48f461504f3ad2.tar.gz
opie-c028ea76557f18eda9d26ee46a48f461504f3ad2.tar.bz2
- improve benchmark reliabilty, especially for SD and CF cards
- split file benchmarks into read/write - add AUTHORS file - encode individual version (it's opie-sysinfo 1.1.0 now) into the .pro file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/AUTHORS4
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp165
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.h2
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro1
4 files changed, 42 insertions, 130 deletions
diff --git a/noncore/settings/sysinfo/AUTHORS b/noncore/settings/sysinfo/AUTHORS
new file mode 100644
index 0000000..a068b93
--- a/dev/null
+++ b/noncore/settings/sysinfo/AUTHORS
@@ -0,0 +1,4 @@
1Trolltech AS.
2Dan Williams <drw@handhelds.org>
3Michael 'Mickey' Lauer <mickeyl@handhelds.org>
4
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 53d4897..f3a6561 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -127,119 +127,119 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
127 127
128 test_alu->setText( 2, "n/a" ); 128 test_alu->setText( 2, "n/a" );
129 test_fpu->setText( 2, "n/a" ); 129 test_fpu->setText( 2, "n/a" );
130 test_txt->setText( 2, "n/a" ); 130 test_txt->setText( 2, "n/a" );
131 test_gfx->setText( 2, "n/a" ); 131 test_gfx->setText( 2, "n/a" );
132 test_ram->setText( 2, "n/a" ); 132 test_ram->setText( 2, "n/a" );
133 test_sd->setText( 2, "n/a" ); 133 test_sd->setText( 2, "n/a" );
134 test_cf->setText( 2, "n/a" ); 134 test_cf->setText( 2, "n/a" );
135 135
136 startButton = new QPushButton( tr( "&Start Tests!" ), this ); 136 startButton = new QPushButton( tr( "&Start Tests!" ), this );
137 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); 137 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) );
138 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); 138 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
139 vb->addWidget( tests, 2 ); 139 vb->addWidget( tests, 2 );
140 140
141 QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); 141 QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" );
142 if ( f.open( IO_ReadOnly ) ) 142 if ( f.open( IO_ReadOnly ) )
143 { 143 {
144 machineCombo = new QComboBox( this ); 144 machineCombo = new QComboBox( this );
145 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); 145 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) );
146 146
147 QTextStream ts( &f ); 147 QTextStream ts( &f );
148 while( !ts.eof() ) 148 while( !ts.eof() )
149 { 149 {
150 QString machline = ts.readLine(); 150 QString machline = ts.readLine();
151 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; 151 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl;
152 QString resline = ts.readLine(); 152 QString resline = ts.readLine();
153 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); 153 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
154 machineCombo->insertItem( machline ); 154 machineCombo->insertItem( machline );
155 } 155 }
156 156
157 QHBoxLayout* hb = new QHBoxLayout( vb ); 157 QHBoxLayout* hb = new QHBoxLayout( vb );
158 hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); 158 hb->addWidget( new QLabel( tr( "Compare To:" ), this ) );
159 hb->addWidget( machineCombo, 2 ); 159 hb->addWidget( machineCombo, 2 );
160 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); 160 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) );
161 } 161 }
162 162
163 vb->addWidget( startButton, 2 ); 163 vb->addWidget( startButton, 2 );
164} 164}
165 165
166 166
167BenchmarkInfo::~BenchmarkInfo() 167BenchmarkInfo::~BenchmarkInfo()
168{} 168{}
169 169
170 170
171void BenchmarkInfo::machineActivated( int index ) 171void BenchmarkInfo::machineActivated( int index )
172{ 172{
173 QStringList* results = machines[ machineCombo->text( index ) ]; 173 QStringList* results = machines[ machineCombo->text( index ) ];
174 if ( !results ) 174 if ( !results )
175 { 175 {
176 odebug << "sysinfo: no results available." << oendl; 176 odebug << "sysinfo: no results available." << oendl;
177 return; 177 return;
178 } 178 }
179 QStringList::Iterator it = results->begin(); 179 QStringList::Iterator it = results->begin();
180 test_alu->setText( 2, *(it++) ); 180 test_alu->setText( 2, *(it++) );
181 test_fpu->setText( 2, *(it++) ); 181 test_fpu->setText( 2, *(it++) );
182 test_txt->setText( 2, *(it++) ); 182 test_txt->setText( 2, *(it++) );
183 test_gfx->setText( 2, *(it++) ); 183 test_gfx->setText( 2, *(it++) );
184 test_ram->setText( 2, *(it++) ); 184 test_ram->setText( 2, *(it++) );
185 test_sd->setText( 2, *(it++) ); 185 test_sd->setText( 2, *(it++) );
186 test_cf->setText( 2, *(it++) ); 186 test_cf->setText( 2, *(it++) );
187} 187}
188 188
189 189
190void BenchmarkInfo::run() 190void BenchmarkInfo::run()
191{ 191{
192 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); 192 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" );
193 qApp->processEvents(); 193 qApp->processEvents();
194 QTime t; 194 QTime t;
195 195
196 if ( test_alu->isOn() ) 196 if ( test_alu->isOn() )
197 { 197 {
198 int d = round( dhry_main( DHRYSTONE_RUNS ) ); 198 int d = round( dhry_main( DHRYSTONE_RUNS ) );
199 test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); 199 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) );
200 test_alu->setOn( false ); 200 test_alu->setOn( false );
201 } 201 }
202 202
203 if ( test_fpu->isOn() ) 203 if ( test_fpu->isOn() )
204 { 204 {
205 t.start(); 205 t.start();
206 BenchFFT(); 206 BenchFFT();
207 test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); 207 test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );;
208 test_fpu->setOn( false ); 208 test_fpu->setOn( false );
209 } 209 }
210 210
211 if ( test_txt->isOn() ) 211 if ( test_txt->isOn() )
212 { 212 {
213 int value = textRendering( TEST_DURATION ); 213 int value = textRendering( TEST_DURATION );
214 test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); 214 test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) );
215 test_txt->setOn( false ); 215 test_txt->setOn( false );
216 } 216 }
217 217
218 if ( test_gfx->isOn() ) 218 if ( test_gfx->isOn() )
219 { 219 {
220 int value = gfxRendering( TEST_DURATION ); 220 int value = gfxRendering( TEST_DURATION );
221 test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests 221 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4 / TEST_DURATION ) ); // 4 tests
222 test_gfx->setOn( false ); 222 test_gfx->setOn( false );
223 } 223 }
224 224
225 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA 225 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA
226 { 226 {
227 performFileTest( "/tmp/benchmarkFile.dat", test_ram ); 227 performFileTest( "/tmp/benchmarkFile.dat", test_ram );
228 } 228 }
229 229
230 if ( test_cf->isOn() ) 230 if ( test_cf->isOn() )
231 { 231 {
232 OStorageInfo storage; 232 OStorageInfo storage;
233 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); 233 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
234 } 234 }
235 235
236 if ( test_sd->isOn() ) 236 if ( test_sd->isOn() )
237 { 237 {
238 OStorageInfo storage; 238 OStorageInfo storage;
239 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); 239 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd );
240 } 240 }
241 241
242 startButton->setText( tr( "&Start Tests!" ) ); 242 startButton->setText( tr( "&Start Tests!" ) );
243} 243}
244 244
245 245
@@ -319,162 +319,71 @@ int BenchmarkInfo::gfxRendering( int seconds )
319 stop = t.elapsed() + seconds*1000; 319 stop = t.elapsed() + seconds*1000;
320 320
321 while ( t.elapsed() < stop ) 321 while ( t.elapsed() < stop )
322 { 322 {
323 int k = rand() % 9; 323 int k = rand() % 9;
324 br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 324 br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
325 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 );
326 ++loops; 326 ++loops;
327 } 327 }
328 328
329 QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); 329 QPixmap p = Resource::loadPixmap( "sysinfo/pattern" );
330 t.restart(); 330 t.restart();
331 stop = t.elapsed() + seconds*1000; 331 stop = t.elapsed() + seconds*1000;
332 332
333 while ( t.elapsed() < stop ) 333 while ( t.elapsed() < stop )
334 { 334 {
335 bpw.p.drawPixmap( rand()%w, rand()%h, p ); 335 bpw.p.drawPixmap( rand()%w, rand()%h, p );
336 ++loops; 336 ++loops;
337 } 337 }
338 338
339 return loops; 339 return loops;
340 340
341} 341}
342 342
343const unsigned int FILE_TEST_COUNT = 8000;
344const unsigned int FILE_TEST_BLOCKSIZE = 1024;
345
343void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) 346void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item )
344{ 347{
348 QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname;
349 odebug << "performing file test on " << filename << oendl;
350
351 QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename )
352 .arg( FILE_TEST_COUNT )
353 .arg( FILE_TEST_BLOCKSIZE );
354 QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename )
355 .arg( FILE_TEST_COUNT )
356 .arg( FILE_TEST_BLOCKSIZE );
357 ::system( "sync" );
358 odebug << "performing file test on " << filename << oendl;
359
360 int write = 0;
361 int read = 0;
362
345 QTime time; 363 QTime time;
346 time.start(); 364 time.start();
347 if ( writeFile( fname ) && 365 if ( ::system( writeCommand ) == 0 )
348 readFile( fname ) )
349 { 366 {
350 QFile::remove( fname ); 367 write = time.elapsed();
351 item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) );
352 item->setOn( false );
353 } 368 }
354 else 369 else
355 { 370 {
356 item->setText( 1, tr( "error" ) ); 371 item->setText( 1, tr( "error" ) );
372 return;
357 } 373 }
358}
359
360char FileBuf[ BUFF_SIZE + 1 ];
361
362bool BenchmarkInfo::writeFile( const QString& w_path )
363{
364 int i;
365 int k;
366 int n;
367 int pos;
368 int len;
369 char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62
370
371 374
372 // /*------------------------------------ 375 time.restart();
373 int w_len; 376 if ( ::system( readCommand ) == 0 )
374
375 QFile writeFile( w_path );
376 srand( time( NULL ) );
377
378 for ( n = 0 ; n < 20 ; n++ )
379 { 377 {
380 if ( ! writeFile.open( IO_WriteOnly ) ) 378 read = time.elapsed();
381 {
382 writeFile.close();
383 writeFile.remove();
384 return ( false );
385 }
386 // ------------------------------------------ sequential write
387 for ( k = 0 ; k < 256 ; k++ )
388 {
389 n = rand() % 30;
390 memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 );
391 }
392
393 for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ )
394 {
395 w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE );
396 if ( w_len != BUFF_SIZE )
397 {
398 writeFile.close();
399 writeFile.remove();
400 return ( false );
401 }
402 writeFile.flush();
403 }
404 // ------------------------------------------ random write
405 for ( i = 0 ; i < 400 ; i++ )
406 {
407 len = rand() % 90 + 4000;
408 for ( k = 0 ; k < 128 ; k++ )
409 {
410 n = rand() % 30;
411 memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 );
412 }
413 pos = rand() % ( FILE_SIZE - BUFF_SIZE );
414
415 writeFile.at( pos );
416 w_len = writeFile.writeBlock( FileBuf, len );
417 if ( w_len != len )
418 {
419 writeFile.close();
420 writeFile.remove();
421 return ( false );
422 }
423 writeFile.flush();
424 }
425 writeFile.close();
426 } 379 }
427 return ( true ); 380 else
428
429}
430
431
432bool BenchmarkInfo::readFile( const QString& r_path )
433{
434 int i;
435 int k;
436 int len;
437 int pos;
438 int r_len;
439
440 QFile readFile( r_path );
441 srand( time( NULL ) );
442
443 for ( k = 0 ; k < 200 ; k++ )
444 { 381 {
445 if ( ! readFile.open( IO_ReadOnly ) ) 382 item->setText( 1, tr( "error" ) );
446 { 383 return;
447 readFile.remove();
448 return ( false );
449 }
450 // ------------------------------------------ sequential read
451 readFile.at( 0 );
452 for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ )
453 {
454 readFile.at( i * BUFF_SIZE );
455 r_len = readFile.readBlock( FileBuf, BUFF_SIZE );
456 if ( r_len != BUFF_SIZE )
457 {
458 readFile.close();
459 readFile.remove();
460 return ( false );
461 }
462 }
463 // ------------------------------------------ random read
464 for ( i = 0 ; i < 1000 ; i++ )
465 {
466 len = rand() % 120 + 8;
467 pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE );
468 readFile.at( pos );
469 r_len = readFile.readBlock( FileBuf, len );
470 if ( r_len != len )
471 {
472 readFile.close();
473 readFile.remove();
474 return ( false );
475 }
476 }
477 readFile.close();
478 } 384 }
479 return ( true ); 385
386 QFile::remove( filename );
387 item->setText( 1, QString().sprintf( "%.2f kb/s, %.2f kb/s", FILE_TEST_COUNT / ( read / 1000.0 ), FILE_TEST_COUNT / ( write / 1000.0 ) ) );
388 item->setOn( false );
480} 389}
diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h
index 0a61134..3b0a33c 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.h
+++ b/noncore/settings/sysinfo/benchmarkinfo.h
@@ -40,30 +40,28 @@ public:
40 Opie::Ui::OCheckListItem* test_txt; 40 Opie::Ui::OCheckListItem* test_txt;
41 Opie::Ui::OCheckListItem* test_gfx; 41 Opie::Ui::OCheckListItem* test_gfx;
42 Opie::Ui::OCheckListItem* test_ram; 42 Opie::Ui::OCheckListItem* test_ram;
43 Opie::Ui::OCheckListItem* test_sd; 43 Opie::Ui::OCheckListItem* test_sd;
44 Opie::Ui::OCheckListItem* test_cf; 44 Opie::Ui::OCheckListItem* test_cf;
45 45
46 bool main_rd; 46 bool main_rd;
47 bool main_wt; 47 bool main_wt;
48 bool sd_rd; 48 bool sd_rd;
49 bool sd_wt; 49 bool sd_wt;
50 bool cf_rd; 50 bool cf_rd;
51 bool cf_wt; 51 bool cf_wt;
52 52
53 QClipboard* clb; 53 QClipboard* clb;
54 QComboBox* machineCombo; 54 QComboBox* machineCombo;
55 Opie::Ui::OListView* tests; 55 Opie::Ui::OListView* tests;
56 QPushButton* startButton; 56 QPushButton* startButton;
57 QDict <QStringList> machines; 57 QDict <QStringList> machines;
58 58
59 int textRendering( int ); 59 int textRendering( int );
60 int gfxRendering( int ); 60 int gfxRendering( int );
61 void performFileTest( const QString& fname, Opie::Ui::OCheckListItem* item ); 61 void performFileTest( const QString& fname, Opie::Ui::OCheckListItem* item );
62 62
63private slots: 63private slots:
64 bool writeFile( const QString& );
65 bool readFile( const QString& );
66 void run(); 64 void run();
67 void machineActivated( int ); 65 void machineActivated( int );
68}; 66};
69 67
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
index 7974713..58f6eb0 100644
--- a/noncore/settings/sysinfo/sysinfo.pro
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -8,26 +8,27 @@ HEADERS = \
8 modulesinfo.h \ 8 modulesinfo.h \
9 detail.h \ 9 detail.h \
10 contrib/dhry.h \ 10 contrib/dhry.h \
11 benchmarkinfo.h \ 11 benchmarkinfo.h \
12 versioninfo.h \ 12 versioninfo.h \
13 sysinfo.h 13 sysinfo.h
14SOURCES = main.cpp \ 14SOURCES = main.cpp \
15 memory.cpp \ 15 memory.cpp \
16 graph.cpp \ 16 graph.cpp \
17 load.cpp \ 17 load.cpp \
18 storage.cpp \ 18 storage.cpp \
19 processinfo.cpp \ 19 processinfo.cpp \
20 modulesinfo.cpp \ 20 modulesinfo.cpp \
21 detail.cpp \ 21 detail.cpp \
22 contrib/dhry.c contrib/fft.c \ 22 contrib/dhry.c contrib/fft.c \
23 benchmarkinfo.cpp \ 23 benchmarkinfo.cpp \
24 versioninfo.cpp \ 24 versioninfo.cpp \
25 sysinfo.cpp 25 sysinfo.cpp
26 26
27INCLUDEPATH += $(OPIEDIR)/include 27INCLUDEPATH += $(OPIEDIR)/include
28DEPENDPATH += $(OPIEDIR)/include 28DEPENDPATH += $(OPIEDIR)/include
29LIBS += -lqpe -lopiecore2 -lopieui2 29LIBS += -lqpe -lopiecore2 -lopieui2
30DEFINES += UNIX 30DEFINES += UNIX
31TARGET = sysinfo 31TARGET = sysinfo
32VERSION = 1.1.0
32 33
33include ( $(OPIEDIR)/include.pro ) 34include ( $(OPIEDIR)/include.pro )