summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 47be13c..be7e4b6 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -151,261 +151,261 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
151 QTextStream ts( &f ); 151 QTextStream ts( &f );
152 while( !ts.eof() ) 152 while( !ts.eof() )
153 { 153 {
154 QString machline = ts.readLine(); 154 QString machline = ts.readLine();
155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; 155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl;
156 QString resline = ts.readLine(); 156 QString resline = ts.readLine();
157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); 157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
158 machineCombo->insertItem( machline ); 158 machineCombo->insertItem( machline );
159 } 159 }
160 160
161 QHBoxLayout* hb = new QHBoxLayout( vb ); 161 QHBoxLayout* hb = new QHBoxLayout( vb );
162 hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); 162 hb->addWidget( new QLabel( tr( "Compare To:" ), this ) );
163 hb->addWidget( machineCombo, 2 ); 163 hb->addWidget( machineCombo, 2 );
164 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); 164 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) );
165 } 165 }
166 166
167 vb->addWidget( startButton, 2 ); 167 vb->addWidget( startButton, 2 );
168} 168}
169 169
170 170
171BenchmarkInfo::~BenchmarkInfo() 171BenchmarkInfo::~BenchmarkInfo()
172{} 172{}
173 173
174 174
175void BenchmarkInfo::machineActivated( int index ) 175void BenchmarkInfo::machineActivated( int index )
176{ 176{
177 QStringList* results = machines[ machineCombo->text( index ) ]; 177 QStringList* results = machines[ machineCombo->text( index ) ];
178 if ( !results ) 178 if ( !results )
179 { 179 {
180 odebug << "sysinfo: no results available." << oendl; 180 odebug << "sysinfo: no results available." << oendl;
181 return; 181 return;
182 } 182 }
183 QStringList::Iterator it = results->begin(); 183 QStringList::Iterator it = results->begin();
184 test_alu->setText( 2, *(it++) ); 184 test_alu->setText( 2, *(it++) );
185 test_fpu->setText( 2, *(it++) ); 185 test_fpu->setText( 2, *(it++) );
186 test_txt->setText( 2, *(it++) ); 186 test_txt->setText( 2, *(it++) );
187 test_gfx->setText( 2, *(it++) ); 187 test_gfx->setText( 2, *(it++) );
188 test_ram->setText( 2, *(it++) ); 188 test_ram->setText( 2, *(it++) );
189#ifndef QT_QWS_RAMSES 189#ifndef QT_QWS_RAMSES
190 test_sd->setText( 2, *(it++) ); 190 test_sd->setText( 2, *(it++) );
191 test_cf->setText( 2, *(it++) ); 191 test_cf->setText( 2, *(it++) );
192#endif 192#endif
193} 193}
194 194
195 195
196void BenchmarkInfo::run() 196void BenchmarkInfo::run()
197{ 197{
198 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); 198 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" );
199 qApp->processEvents(); 199 qApp->processEvents();
200 QTime t; 200 QTime t;
201 201
202 if ( test_alu->isOn() ) 202 if ( test_alu->isOn() )
203 { 203 {
204 int d = round( dhry_main( DHRYSTONE_RUNS ) ); 204 int d = round( dhry_main( DHRYSTONE_RUNS ) );
205 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); 205 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) );
206 test_alu->setOn( false ); 206 test_alu->setOn( false );
207 } 207 }
208 208
209 if ( test_fpu->isOn() ) 209 if ( test_fpu->isOn() )
210 { 210 {
211 t.start(); 211 t.start();
212 BenchFFT(); 212 BenchFFT();
213 test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );; 213 test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );;
214 test_fpu->setOn( false ); 214 test_fpu->setOn( false );
215 } 215 }
216 216
217 if ( test_txt->isOn() ) 217 if ( test_txt->isOn() )
218 { 218 {
219 int value = textRendering( TEST_DURATION ); 219 int value = textRendering( TEST_DURATION );
220 test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); 220 test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) );
221 test_txt->setOn( false ); 221 test_txt->setOn( false );
222 } 222 }
223 223
224 if ( test_gfx->isOn() ) 224 if ( test_gfx->isOn() )
225 { 225 {
226 int value = gfxRendering( TEST_DURATION ); 226 int value = gfxRendering( TEST_DURATION );
227 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests 227 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests
228 test_gfx->setOn( false ); 228 test_gfx->setOn( false );
229 } 229 }
230 230
231 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA 231 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA
232 { 232 {
233 performFileTest( "/tmp/benchmarkFile.dat", test_ram ); 233 performFileTest( "/tmp/benchmarkFile.dat", test_ram );
234 } 234 }
235 235
236#ifndef QT_QWS_RAMSES 236#ifndef QT_QWS_RAMSES
237 if ( test_cf->isOn() ) 237 if ( test_cf->isOn() )
238 { 238 {
239 OStorageInfo storage; 239 OStorageInfo storage;
240 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); 240 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
241 } 241 }
242 242
243 if ( test_sd->isOn() ) 243 if ( test_sd->isOn() )
244 { 244 {
245 OStorageInfo storage; 245 OStorageInfo storage;
246 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); 246 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd );
247 } 247 }
248#endif 248#endif
249 249
250 startButton->setText( tr( "&Start Tests!" ) ); 250 startButton->setText( tr( "&Start Tests!" ) );
251} 251}
252 252
253 253
254int BenchmarkInfo::textRendering( int seconds ) 254int BenchmarkInfo::textRendering( int seconds )
255{ 255{
256 QTime t; 256 QTime t;
257 t.start(); 257 t.start();
258 int stop = t.elapsed() + seconds * 1000; 258 int stop = t.elapsed() + seconds * 1000;
259 259
260 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; 260 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
261 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; 261 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
262 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; 262 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
263 const QString text( "Opie Benchmark Test" ); 263 const QString text( "Opie Benchmark Test" );
264 264
265 int w = QApplication::desktop()->width(); 265 int w = QApplication::desktop()->width();
266 int h = QApplication::desktop()->height(); 266 int h = QApplication::desktop()->height();
267 267
268 srand( time( NULL ) ); 268 srand( time( NULL ) );
269 269
270 BenchmarkPaintWidget bpw; 270 BenchmarkPaintWidget bpw;
271 271
272 int loops = 0; 272 int loops = 0;
273 273
274 while ( t.elapsed() < stop ) 274 while ( t.elapsed() < stop )
275 { 275 {
276 int k = rand() % 9; 276 int k = rand() % 9;
277 int s = rand() % 100; 277 int s = rand() % 100;
278 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 278 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
279 bpw.p.setFont( QFont( "Vera", s ) ); 279 bpw.p.setFont( QFont( "Vera", s ) );
280 bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); 280 bpw.p.drawText( rand() % w, rand() % h, text, text.length() );
281 ++loops; 281 ++loops;
282 } 282 }
283 283
284 return loops * text.length(); 284 return loops * text.length();
285} 285}
286 286
287int BenchmarkInfo::gfxRendering( int seconds ) 287int BenchmarkInfo::gfxRendering( int seconds )
288{ 288{
289 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; 289 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
290 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; 290 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
291 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; 291 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
292 292
293 int w = QApplication::desktop()->width(); 293 int w = QApplication::desktop()->width();
294 int h = QApplication::desktop()->height(); 294 int h = QApplication::desktop()->height();
295 295
296 srand( time( NULL ) ); 296 srand( time( NULL ) );
297 297
298 BenchmarkPaintWidget bpw; 298 BenchmarkPaintWidget bpw;
299 299
300 QTime t; 300 QTime t;
301 t.start(); 301 t.start();
302 int stop = t.elapsed() + seconds*1000; 302 int stop = t.elapsed() + seconds*1000;
303 int loops = 0; 303 int loops = 0;
304 304
305 while ( t.elapsed() < stop ) 305 while ( t.elapsed() < stop )
306 { 306 {
307 int k = rand() % 9; 307 int k = rand() % 9;
308 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 308 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
309 bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); 309 bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h );
310 ++loops; 310 ++loops;
311 } 311 }
312 312
313 t.restart(); 313 t.restart();
314 stop = t.elapsed() + seconds*1000; 314 stop = t.elapsed() + seconds*1000;
315 315
316 while ( t.elapsed() < stop ) 316 while ( t.elapsed() < stop )
317 { 317 {
318 int k = rand() % 9; 318 int k = rand() % 9;
319 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 319 bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
320 bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); 320 bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 );
321 ++loops; 321 ++loops;
322 } 322 }
323 323
324 QBrush br1; 324 QBrush br1;
325 br1.setStyle( SolidPattern ); 325 br1.setStyle( SolidPattern );
326 t.restart(); 326 t.restart();
327 stop = t.elapsed() + seconds*1000; 327 stop = t.elapsed() + seconds*1000;
328 328
329 while ( t.elapsed() < stop ) 329 while ( t.elapsed() < stop )
330 { 330 {
331 int k = rand() % 9; 331 int k = rand() % 9;
332 br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); 332 br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
333 bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); 333 bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 );
334 ++loops; 334 ++loops;
335 } 335 }
336 336
337 QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); 337 QPixmap p = Resource::loadPixmap( "sysinfo/pattern" );
338 t.restart(); 338 t.restart();
339 stop = t.elapsed() + seconds*1000; 339 stop = t.elapsed() + seconds*1000;
340 340
341 while ( t.elapsed() < stop ) 341 while ( t.elapsed() < stop )
342 { 342 {
343 bpw.p.drawPixmap( rand()%w, rand()%h, p ); 343 bpw.p.drawPixmap( rand()%w, rand()%h, p );
344 ++loops; 344 ++loops;
345 } 345 }
346 346
347 return loops; 347 return loops;
348 348
349} 349}
350 350
351const unsigned int FILE_TEST_COUNT = 8000; 351const unsigned int FILE_TEST_COUNT = 8000;
352const unsigned int FILE_TEST_BLOCKSIZE = 1024; 352const unsigned int FILE_TEST_BLOCKSIZE = 1024;
353 353
354void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) 354void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item )
355{ 355{
356 QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; 356 QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname;
357 odebug << "performing file test on " << filename << oendl; 357 odebug << "performing file test on " << filename << oendl;
358 358
359 QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) 359 QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename )
360 .arg( FILE_TEST_COUNT ) 360 .arg( FILE_TEST_COUNT )
361 .arg( FILE_TEST_BLOCKSIZE ); 361 .arg( FILE_TEST_BLOCKSIZE );
362 QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) 362 QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename )
363 .arg( FILE_TEST_COUNT ) 363 .arg( FILE_TEST_COUNT )
364 .arg( FILE_TEST_BLOCKSIZE ); 364 .arg( FILE_TEST_BLOCKSIZE );
365 ::system( "sync" ); 365 ::system( "sync" );
366 odebug << "performing file test on " << filename << oendl; 366 odebug << "performing file test on " << filename << oendl;
367 367
368 int write = 0; 368 int write = 0;
369 int read = 0; 369 int read = 0;
370 370
371 QTime time; 371 QTime time;
372 time.start(); 372 time.start();
373 if ( ::system( writeCommand ) == 0 ) 373 if ( ::system( writeCommand ) == 0 )
374 { 374 {
375 write = time.elapsed(); 375 write = time.elapsed();
376 } 376 }
377 else 377 else
378 { 378 {
379 item->setText( 1, tr( "error" ) ); 379 item->setText( 1, tr( "error" ) );
380 return; 380 return;
381 } 381 }
382 382
383 time.restart(); 383 time.restart();
384 if ( ::system( readCommand ) == 0 ) 384 if ( ::system( readCommand ) == 0 )
385 { 385 {
386 read = time.elapsed(); 386 read = time.elapsed();
387 } 387 }
388 else 388 else
389 { 389 {
390 item->setText( 1, tr( "error" ) ); 390 item->setText( 1, tr( "error" ) );
391 return; 391 return;
392 } 392 }
393 393
394 QFile::remove( filename ); 394 QFile::remove( filename );
395 double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 ); 395 double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 );
396 QString readUnit = "kB/s"; 396 QString readUnit = "kB/s";
397 if ( readSpeed > 1024 ) 397 if ( readSpeed > 1024 )
398 { 398 {
399 readSpeed = readSpeed / 1024.0; 399 readSpeed = readSpeed / 1024.0;
400 readUnit = "MB/s"; 400 readUnit = "MB/s";
401 } 401 }
402 double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 ); 402 double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 );
403 QString writeUnit = "kb/s"; 403 QString writeUnit = "kb/s";
404 if ( writeSpeed > 1024 ) 404 if ( writeSpeed > 1024 )
405 { 405 {
406 writeSpeed = writeSpeed / 1024.0; 406 writeSpeed = writeSpeed / 1024.0;
407 writeUnit = "MBb/s"; 407 writeUnit = "MB/s";
408 } 408 }
409 item->setText( 1, QString().sprintf( "%.2f %s, %.2f %s", readSpeed, readUnit.latin1(), writeSpeed, writeUnit.latin1() ) ); 409 item->setText( 1, QString().sprintf( "%.2f %s, %.2f %s", readSpeed, readUnit.latin1(), writeSpeed, writeUnit.latin1() ) );
410 item->setOn( false ); 410 item->setOn( false );
411} 411}