summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp16
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
@@ -323,67 +323,81 @@ int BenchmarkInfo::gfxRendering( int seconds )
int k = rand() % 9;
br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 );
++loops;
}
QPixmap p = Resource::loadPixmap( "sysinfo/pattern" );
t.restart();
stop = t.elapsed() + seconds*1000;
while ( t.elapsed() < stop )
{
bpw.p.drawPixmap( rand()%w, rand()%h, p );
++loops;
}
return loops;
}
const unsigned int FILE_TEST_COUNT = 8000;
const unsigned int FILE_TEST_BLOCKSIZE = 1024;
void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item )
{
QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname;
odebug << "performing file test on " << filename << oendl;
QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename )
.arg( FILE_TEST_COUNT )
.arg( FILE_TEST_BLOCKSIZE );
QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename )
.arg( FILE_TEST_COUNT )
.arg( FILE_TEST_BLOCKSIZE );
::system( "sync" );
odebug << "performing file test on " << filename << oendl;
int write = 0;
int read = 0;
QTime time;
time.start();
if ( ::system( writeCommand ) == 0 )
{
write = time.elapsed();
}
else
{
item->setText( 1, tr( "error" ) );
return;
}
time.restart();
if ( ::system( readCommand ) == 0 )
{
read = time.elapsed();
}
else
{
item->setText( 1, tr( "error" ) );
return;
}
QFile::remove( filename );
- item->setText( 1, QString().sprintf( "%.2f kb/s, %.2f kb/s", FILE_TEST_COUNT / ( read / 1000.0 ), FILE_TEST_COUNT / ( write / 1000.0 ) ) );
+ double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 );
+ QString readUnit = "kb/s";
+ if ( readSpeed > 1024 )
+ {
+ readSpeed = readSpeed / 1024.0;
+ readUnit = "mb/s";
+ }
+ double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 );
+ QString writeUnit = "kb/s";
+ if ( writeSpeed > 1024 )
+ {
+ writeSpeed = writeSpeed / 1024.0;
+ writeUnit = "mb/s";
+ }
+ item->setText( 1, QString().sprintf( "%.2f %s, %.2f %s", readSpeed, readUnit.latin1(), writeSpeed, writeUnit.latin1() ) );
item->setOn( false );
}