author | mickeyl <mickeyl> | 2004-08-27 09:43:17 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-08-27 09:43:17 (UTC) |
commit | a6e7ebcee38719a9f33ede08ed4c8a364c2ecb20 (patch) (unidiff) | |
tree | 1c5674ddb8de987ac8a42d6c58597684ab1e43a4 | |
parent | 2b5ae694fd875ed90c764d430891fbe4548688f2 (diff) | |
download | opie-a6e7ebcee38719a9f33ede08ed4c8a364c2ecb20.zip opie-a6e7ebcee38719a9f33ede08ed4c8a364c2ecb20.tar.gz opie-a6e7ebcee38719a9f33ede08ed4c8a364c2ecb20.tar.bz2 |
adapt unit for file benchmarks, if value too high for kb/sec
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index f3a6561..8497c8b 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -339,51 +339,65 @@ int BenchmarkInfo::gfxRendering( int seconds ) | |||
339 | return loops; | 339 | return loops; |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | const unsigned int FILE_TEST_COUNT = 8000; | 343 | const unsigned int FILE_TEST_COUNT = 8000; |
344 | const unsigned int FILE_TEST_BLOCKSIZE = 1024; | 344 | const unsigned int FILE_TEST_BLOCKSIZE = 1024; |
345 | 345 | ||
346 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) | 346 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) |
347 | { | 347 | { |
348 | QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; | 348 | QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; |
349 | odebug << "performing file test on " << filename << oendl; | 349 | odebug << "performing file test on " << filename << oendl; |
350 | 350 | ||
351 | QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) | 351 | QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) |
352 | .arg( FILE_TEST_COUNT ) | 352 | .arg( FILE_TEST_COUNT ) |
353 | .arg( FILE_TEST_BLOCKSIZE ); | 353 | .arg( FILE_TEST_BLOCKSIZE ); |
354 | QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) | 354 | QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) |
355 | .arg( FILE_TEST_COUNT ) | 355 | .arg( FILE_TEST_COUNT ) |
356 | .arg( FILE_TEST_BLOCKSIZE ); | 356 | .arg( FILE_TEST_BLOCKSIZE ); |
357 | ::system( "sync" ); | 357 | ::system( "sync" ); |
358 | odebug << "performing file test on " << filename << oendl; | 358 | odebug << "performing file test on " << filename << oendl; |
359 | 359 | ||
360 | int write = 0; | 360 | int write = 0; |
361 | int read = 0; | 361 | int read = 0; |
362 | 362 | ||
363 | QTime time; | 363 | QTime time; |
364 | time.start(); | 364 | time.start(); |
365 | if ( ::system( writeCommand ) == 0 ) | 365 | if ( ::system( writeCommand ) == 0 ) |
366 | { | 366 | { |
367 | write = time.elapsed(); | 367 | write = time.elapsed(); |
368 | } | 368 | } |
369 | else | 369 | else |
370 | { | 370 | { |
371 | item->setText( 1, tr( "error" ) ); | 371 | item->setText( 1, tr( "error" ) ); |
372 | return; | 372 | return; |
373 | } | 373 | } |
374 | 374 | ||
375 | time.restart(); | 375 | time.restart(); |
376 | if ( ::system( readCommand ) == 0 ) | 376 | if ( ::system( readCommand ) == 0 ) |
377 | { | 377 | { |
378 | read = time.elapsed(); | 378 | read = time.elapsed(); |
379 | } | 379 | } |
380 | else | 380 | else |
381 | { | 381 | { |
382 | item->setText( 1, tr( "error" ) ); | 382 | item->setText( 1, tr( "error" ) ); |
383 | return; | 383 | return; |
384 | } | 384 | } |
385 | 385 | ||
386 | QFile::remove( filename ); | 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 ) ) ); | 387 | double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 ); |
388 | QString readUnit = "kb/s"; | ||
389 | if ( readSpeed > 1024 ) | ||
390 | { | ||
391 | readSpeed = readSpeed / 1024.0; | ||
392 | readUnit = "mb/s"; | ||
393 | } | ||
394 | double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 ); | ||
395 | QString writeUnit = "kb/s"; | ||
396 | if ( writeSpeed > 1024 ) | ||
397 | { | ||
398 | writeSpeed = writeSpeed / 1024.0; | ||
399 | writeUnit = "mb/s"; | ||
400 | } | ||
401 | item->setText( 1, QString().sprintf( "%.2f %s, %.2f %s", readSpeed, readUnit.latin1(), writeSpeed, writeUnit.latin1() ) ); | ||
388 | item->setOn( false ); | 402 | item->setOn( false ); |
389 | } | 403 | } |