-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index fde032a..793fcb1 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -214,195 +214,195 @@ void BenchmarkInfo::run() | |||
214 | if ( test_txt->isOn() ) | 214 | if ( test_txt->isOn() ) |
215 | { | 215 | { |
216 | int value = textRendering( TEST_DURATION ); | 216 | int value = textRendering( TEST_DURATION ); |
217 | test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); | 217 | test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); |
218 | test_txt->setOn( false ); | 218 | test_txt->setOn( false ); |
219 | } | 219 | } |
220 | 220 | ||
221 | if ( test_gfx->isOn() ) | 221 | if ( test_gfx->isOn() ) |
222 | { | 222 | { |
223 | int value = gfxRendering( TEST_DURATION ); | 223 | int value = gfxRendering( TEST_DURATION ); |
224 | test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests | 224 | test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests |
225 | test_gfx->setOn( false ); | 225 | test_gfx->setOn( false ); |
226 | } | 226 | } |
227 | 227 | ||
228 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 228 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
229 | { | 229 | { |
230 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 230 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
231 | } | 231 | } |
232 | 232 | ||
233 | #ifndef QT_QWS_RAMSES | 233 | #ifndef QT_QWS_RAMSES |
234 | if ( test_cf->isOn() ) | 234 | if ( test_cf->isOn() ) |
235 | { | 235 | { |
236 | OStorageInfo storage; | 236 | OStorageInfo storage; |
237 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 237 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
238 | } | 238 | } |
239 | 239 | ||
240 | if ( test_sd->isOn() ) | 240 | if ( test_sd->isOn() ) |
241 | { | 241 | { |
242 | OStorageInfo storage; | 242 | OStorageInfo storage; |
243 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 243 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
244 | } | 244 | } |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | startButton->setText( tr( "&Start Tests!" ) ); | 247 | startButton->setText( tr( "&Start Tests!" ) ); |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | int BenchmarkInfo::textRendering( int seconds ) | 251 | int BenchmarkInfo::textRendering( int seconds ) |
252 | { | 252 | { |
253 | QTime t; | 253 | QTime t; |
254 | t.start(); | 254 | t.start(); |
255 | int stop = t.elapsed() + seconds * 1000; | 255 | int stop = t.elapsed() + seconds * 1000; |
256 | 256 | ||
257 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 257 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
258 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 258 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
259 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 259 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
260 | const QString text( "Opie Benchmark Test" ); | 260 | const QString text( "Opie Benchmark Test" ); |
261 | 261 | ||
262 | int w = QApplication::desktop()->width(); | 262 | int w = QApplication::desktop()->width(); |
263 | int h = QApplication::desktop()->height(); | 263 | int h = QApplication::desktop()->height(); |
264 | 264 | ||
265 | srand( time( NULL ) ); | 265 | srand( time( NULL ) ); |
266 | 266 | ||
267 | BenchmarkPaintWidget bpw; | 267 | BenchmarkPaintWidget bpw; |
268 | 268 | ||
269 | int loops = 0; | 269 | int loops = 0; |
270 | 270 | ||
271 | while ( t.elapsed() < stop ) | 271 | while ( t.elapsed() < stop ) |
272 | { | 272 | { |
273 | int k = rand() % 9; | 273 | int k = rand() % 9; |
274 | int s = rand() % 100; | 274 | int s = rand() % 100; |
275 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 275 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
276 | bpw.p.setFont( QFont( "Vera", s ) ); | 276 | bpw.p.setFont( QFont( "Vera", s ) ); |
277 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 277 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
278 | ++loops; | 278 | ++loops; |
279 | } | 279 | } |
280 | 280 | ||
281 | return loops * text.length(); | 281 | return loops * text.length(); |
282 | } | 282 | } |
283 | 283 | ||
284 | int BenchmarkInfo::gfxRendering( int seconds ) | 284 | int BenchmarkInfo::gfxRendering( int seconds ) |
285 | { | 285 | { |
286 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 286 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
287 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 287 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
288 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 288 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
289 | 289 | ||
290 | int w = QApplication::desktop()->width(); | 290 | int w = QApplication::desktop()->width(); |
291 | int h = QApplication::desktop()->height(); | 291 | int h = QApplication::desktop()->height(); |
292 | 292 | ||
293 | srand( time( NULL ) ); | 293 | srand( time( NULL ) ); |
294 | 294 | ||
295 | BenchmarkPaintWidget bpw; | 295 | BenchmarkPaintWidget bpw; |
296 | 296 | ||
297 | QTime t; | 297 | QTime t; |
298 | t.start(); | 298 | t.start(); |
299 | int stop = t.elapsed() + seconds*1000; | 299 | int stop = t.elapsed() + seconds*1000; |
300 | int loops = 0; | 300 | int loops = 0; |
301 | 301 | ||
302 | while ( t.elapsed() < stop ) | 302 | while ( t.elapsed() < stop ) |
303 | { | 303 | { |
304 | int k = rand() % 9; | 304 | int k = rand() % 9; |
305 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 305 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
306 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 306 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
307 | ++loops; | 307 | ++loops; |
308 | } | 308 | } |
309 | 309 | ||
310 | t.restart(); | 310 | t.restart(); |
311 | stop = t.elapsed() + seconds*1000; | 311 | stop = t.elapsed() + seconds*1000; |
312 | 312 | ||
313 | while ( t.elapsed() < stop ) | 313 | while ( t.elapsed() < stop ) |
314 | { | 314 | { |
315 | int k = rand() % 9; | 315 | int k = rand() % 9; |
316 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 316 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
317 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 317 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
318 | ++loops; | 318 | ++loops; |
319 | } | 319 | } |
320 | 320 | ||
321 | QBrush br1; | 321 | QBrush br1; |
322 | br1.setStyle( SolidPattern ); | 322 | br1.setStyle( SolidPattern ); |
323 | t.restart(); | 323 | t.restart(); |
324 | stop = t.elapsed() + seconds*1000; | 324 | stop = t.elapsed() + seconds*1000; |
325 | 325 | ||
326 | while ( t.elapsed() < stop ) | 326 | while ( t.elapsed() < stop ) |
327 | { | 327 | { |
328 | int k = rand() % 9; | 328 | int k = rand() % 9; |
329 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 329 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
330 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 330 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
331 | ++loops; | 331 | ++loops; |
332 | } | 332 | } |
333 | 333 | ||
334 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 334 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
335 | t.restart(); | 335 | t.restart(); |
336 | stop = t.elapsed() + seconds*1000; | 336 | stop = t.elapsed() + seconds*1000; |
337 | 337 | ||
338 | while ( t.elapsed() < stop ) | 338 | while ( t.elapsed() < stop ) |
339 | { | 339 | { |
340 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 340 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
341 | ++loops; | 341 | ++loops; |
342 | } | 342 | } |
343 | 343 | ||
344 | return loops; | 344 | return loops; |
345 | 345 | ||
346 | } | 346 | } |
347 | 347 | ||
348 | const unsigned int FILE_TEST_COUNT = 8000; | 348 | const unsigned int FILE_TEST_COUNT = 8000; |
349 | const unsigned int FILE_TEST_BLOCKSIZE = 1024; | 349 | const unsigned int FILE_TEST_BLOCKSIZE = 1024; |
350 | 350 | ||
351 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) | 351 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) |
352 | { | 352 | { |
353 | QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; | 353 | QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; |
354 | odebug << "performing file test on " << filename << oendl; | 354 | odebug << "performing file test on " << filename << oendl; |
355 | 355 | ||
356 | QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) | 356 | QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) |
357 | .arg( FILE_TEST_COUNT ) | 357 | .arg( FILE_TEST_COUNT ) |
358 | .arg( FILE_TEST_BLOCKSIZE ); | 358 | .arg( FILE_TEST_BLOCKSIZE ); |
359 | QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) | 359 | QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) |
360 | .arg( FILE_TEST_COUNT ) | 360 | .arg( FILE_TEST_COUNT ) |
361 | .arg( FILE_TEST_BLOCKSIZE ); | 361 | .arg( FILE_TEST_BLOCKSIZE ); |
362 | ::system( "sync" ); | 362 | ::system( "sync" ); |
363 | odebug << "performing file test on " << filename << oendl; | 363 | odebug << "performing file test on " << filename << oendl; |
364 | 364 | ||
365 | int write = 0; | 365 | int write = 0; |
366 | int read = 0; | 366 | int read = 0; |
367 | 367 | ||
368 | QTime time; | 368 | QTime time; |
369 | time.start(); | 369 | time.start(); |
370 | if ( ::system( writeCommand ) == 0 ) | 370 | if ( ::system( writeCommand ) == 0 ) |
371 | { | 371 | { |
372 | write = time.elapsed(); | 372 | write = time.elapsed(); |
373 | } | 373 | } |
374 | else | 374 | else |
375 | { | 375 | { |
376 | item->setText( 1, tr( "error" ) ); | 376 | item->setText( 1, tr( "error" ) ); |
377 | return; | 377 | return; |
378 | } | 378 | } |
379 | 379 | ||
380 | time.restart(); | 380 | time.restart(); |
381 | if ( ::system( readCommand ) == 0 ) | 381 | if ( ::system( readCommand ) == 0 ) |
382 | { | 382 | { |
383 | read = time.elapsed(); | 383 | read = time.elapsed(); |
384 | } | 384 | } |
385 | else | 385 | else |
386 | { | 386 | { |
387 | item->setText( 1, tr( "error" ) ); | 387 | item->setText( 1, tr( "error" ) ); |
388 | return; | 388 | return; |
389 | } | 389 | } |
390 | 390 | ||
391 | QFile::remove( filename ); | 391 | QFile::remove( filename ); |
392 | double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 ); | 392 | double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 ); |
393 | QString readUnit = "kB/s"; | 393 | QString readUnit = "kB/s"; |
394 | if ( readSpeed > 1024 ) | 394 | if ( readSpeed > 1024 ) |
395 | { | 395 | { |
396 | readSpeed /= 1024.0; | 396 | readSpeed /= 1024.0; |
397 | readUnit = "MB/s"; | 397 | readUnit = "MB/s"; |
398 | } | 398 | } |
399 | double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 ); | 399 | double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 ); |
400 | QString writeUnit = "kb/s"; | 400 | QString writeUnit = "kb/s"; |
401 | if ( writeSpeed > 1024 ) | 401 | if ( writeSpeed > 1024 ) |
402 | { | 402 | { |
403 | writeSpeed /= 1024.0; | 403 | writeSpeed /= 1024.0; |
404 | writeUnit = "MB/s"; | 404 | writeUnit = "MB/s"; |
405 | } | 405 | } |
406 | item->setText( 1, QString().sprintf( "%.2f %s, %.2f %s", readSpeed, readUnit.latin1(), writeSpeed, writeUnit.latin1() ) ); | 406 | item->setText( 1, QString().sprintf( "%.2f %s; %.2f %s", readSpeed, readUnit.latin1(), writeSpeed, writeUnit.latin1() ) ); |
407 | item->setOn( false ); | 407 | item->setOn( false ); |
408 | } | 408 | } |