summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/benchmarkinfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/benchmarkinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 8497c8b..47be13c 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -93,66 +93,70 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
93 : QWidget( parent, name, wFlags ) 93 : QWidget( parent, name, wFlags )
94{ 94{
95 95
96 setMinimumSize( 200, 150 ); 96 setMinimumSize( 200, 150 );
97 97
98 QVBoxLayout* vb = new QVBoxLayout( this ); 98 QVBoxLayout* vb = new QVBoxLayout( this );
99 vb->setSpacing( 4 ); 99 vb->setSpacing( 4 );
100 vb->setMargin( 4 ); 100 vb->setMargin( 4 );
101 101
102 tests = new OListView( this ); 102 tests = new OListView( this );
103 QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " 103 QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests "
104 "have been performed, and comparison values for one selected device. " 104 "have been performed, and comparison values for one selected device. "
105 "Use the checkboxes to define which tests you want to perform." ) ); 105 "Use the checkboxes to define which tests you want to perform." ) );
106 tests->setMargin( 0 ); 106 tests->setMargin( 0 );
107 tests->addColumn( tr( "Tests" ) ); 107 tests->addColumn( tr( "Tests" ) );
108 tests->addColumn( tr( "Results" ) ); 108 tests->addColumn( tr( "Results" ) );
109 tests->addColumn( tr( "Comparison" ) ); 109 tests->addColumn( tr( "Comparison" ) );
110 tests->setShowSortIndicator( true ); 110 tests->setShowSortIndicator( true );
111 111
112 test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); 112 test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox );
113 test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); 113 test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox );
114 test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); 114 test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox );
115 test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); 115 test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox );
116 test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); 116 test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox );
117#ifndef QT_QWS_RAMSES
117 test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); 118 test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox );
118 test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); 119 test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox );
119 120#endif
120 test_alu->setText( 1, "n/a" ); 121 test_alu->setText( 1, "n/a" );
121 test_fpu->setText( 1, "n/a" ); 122 test_fpu->setText( 1, "n/a" );
122 test_txt->setText( 1, "n/a" ); 123 test_txt->setText( 1, "n/a" );
123 test_gfx->setText( 1, "n/a" ); 124 test_gfx->setText( 1, "n/a" );
124 test_ram->setText( 1, "n/a" ); 125 test_ram->setText( 1, "n/a" );
126#ifndef QT_QWS_RAMSES
125 test_sd->setText( 1, "n/a" ); 127 test_sd->setText( 1, "n/a" );
126 test_cf->setText( 1, "n/a" ); 128 test_cf->setText( 1, "n/a" );
127 129#endif
128 test_alu->setText( 2, "n/a" ); 130 test_alu->setText( 2, "n/a" );
129 test_fpu->setText( 2, "n/a" ); 131 test_fpu->setText( 2, "n/a" );
130 test_txt->setText( 2, "n/a" ); 132 test_txt->setText( 2, "n/a" );
131 test_gfx->setText( 2, "n/a" ); 133 test_gfx->setText( 2, "n/a" );
132 test_ram->setText( 2, "n/a" ); 134 test_ram->setText( 2, "n/a" );
135#ifndef QT_QWS_RAMSES
133 test_sd->setText( 2, "n/a" ); 136 test_sd->setText( 2, "n/a" );
134 test_cf->setText( 2, "n/a" ); 137 test_cf->setText( 2, "n/a" );
138#endif
135 139
136 startButton = new QPushButton( tr( "&Start Tests!" ), this ); 140 startButton = new QPushButton( tr( "&Start Tests!" ), this );
137 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); 141 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) );
138 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); 142 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
139 vb->addWidget( tests, 2 ); 143 vb->addWidget( tests, 2 );
140 144
141 QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); 145 QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" );
142 if ( f.open( IO_ReadOnly ) ) 146 if ( f.open( IO_ReadOnly ) )
143 { 147 {
144 machineCombo = new QComboBox( this ); 148 machineCombo = new QComboBox( this );
145 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); 149 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) );
146 150
147 QTextStream ts( &f ); 151 QTextStream ts( &f );
148 while( !ts.eof() ) 152 while( !ts.eof() )
149 { 153 {
150 QString machline = ts.readLine(); 154 QString machline = ts.readLine();
151 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; 155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl;
152 QString resline = ts.readLine(); 156 QString resline = ts.readLine();
153 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); 157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
154 machineCombo->insertItem( machline ); 158 machineCombo->insertItem( machline );
155 } 159 }
156 160
157 QHBoxLayout* hb = new QHBoxLayout( vb ); 161 QHBoxLayout* hb = new QHBoxLayout( vb );
158 hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); 162 hb->addWidget( new QLabel( tr( "Compare To:" ), this ) );
@@ -161,104 +165,108 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
161 } 165 }
162 166
163 vb->addWidget( startButton, 2 ); 167 vb->addWidget( startButton, 2 );
164} 168}
165 169
166 170
167BenchmarkInfo::~BenchmarkInfo() 171BenchmarkInfo::~BenchmarkInfo()
168{} 172{}
169 173
170 174
171void BenchmarkInfo::machineActivated( int index ) 175void BenchmarkInfo::machineActivated( int index )
172{ 176{
173 QStringList* results = machines[ machineCombo->text( index ) ]; 177 QStringList* results = machines[ machineCombo->text( index ) ];
174 if ( !results ) 178 if ( !results )
175 { 179 {
176 odebug << "sysinfo: no results available." << oendl; 180 odebug << "sysinfo: no results available." << oendl;
177 return; 181 return;
178 } 182 }
179 QStringList::Iterator it = results->begin(); 183 QStringList::Iterator it = results->begin();
180 test_alu->setText( 2, *(it++) ); 184 test_alu->setText( 2, *(it++) );
181 test_fpu->setText( 2, *(it++) ); 185 test_fpu->setText( 2, *(it++) );
182 test_txt->setText( 2, *(it++) ); 186 test_txt->setText( 2, *(it++) );
183 test_gfx->setText( 2, *(it++) ); 187 test_gfx->setText( 2, *(it++) );
184 test_ram->setText( 2, *(it++) ); 188 test_ram->setText( 2, *(it++) );
189#ifndef QT_QWS_RAMSES
185 test_sd->setText( 2, *(it++) ); 190 test_sd->setText( 2, *(it++) );
186 test_cf->setText( 2, *(it++) ); 191 test_cf->setText( 2, *(it++) );
192#endif
187} 193}
188 194
189 195
190void BenchmarkInfo::run() 196void BenchmarkInfo::run()
191{ 197{
192 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); 198 startButton->setText( "> Don't touch! Running Tests! Don't touch! <" );
193 qApp->processEvents(); 199 qApp->processEvents();
194 QTime t; 200 QTime t;
195 201
196 if ( test_alu->isOn() ) 202 if ( test_alu->isOn() )
197 { 203 {
198 int d = round( dhry_main( DHRYSTONE_RUNS ) ); 204 int d = round( dhry_main( DHRYSTONE_RUNS ) );
199 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); 205 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) );
200 test_alu->setOn( false ); 206 test_alu->setOn( false );
201 } 207 }
202 208
203 if ( test_fpu->isOn() ) 209 if ( test_fpu->isOn() )
204 { 210 {
205 t.start(); 211 t.start();
206 BenchFFT(); 212 BenchFFT();
207 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 ) );;
208 test_fpu->setOn( false ); 214 test_fpu->setOn( false );
209 } 215 }
210 216
211 if ( test_txt->isOn() ) 217 if ( test_txt->isOn() )
212 { 218 {
213 int value = textRendering( TEST_DURATION ); 219 int value = textRendering( TEST_DURATION );
214 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 ) );
215 test_txt->setOn( false ); 221 test_txt->setOn( false );
216 } 222 }
217 223
218 if ( test_gfx->isOn() ) 224 if ( test_gfx->isOn() )
219 { 225 {
220 int value = gfxRendering( TEST_DURATION ); 226 int value = gfxRendering( TEST_DURATION );
221 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4 / TEST_DURATION ) ); // 4 tests 227 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests
222 test_gfx->setOn( false ); 228 test_gfx->setOn( false );
223 } 229 }
224 230
225 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
226 { 232 {
227 performFileTest( "/tmp/benchmarkFile.dat", test_ram ); 233 performFileTest( "/tmp/benchmarkFile.dat", test_ram );
228 } 234 }
229 235
236#ifndef QT_QWS_RAMSES
230 if ( test_cf->isOn() ) 237 if ( test_cf->isOn() )
231 { 238 {
232 OStorageInfo storage; 239 OStorageInfo storage;
233 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); 240 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
234 } 241 }
235 242
236 if ( test_sd->isOn() ) 243 if ( test_sd->isOn() )
237 { 244 {
238 OStorageInfo storage; 245 OStorageInfo storage;
239 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); 246 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd );
240 } 247 }
248#endif
241 249
242 startButton->setText( tr( "&Start Tests!" ) ); 250 startButton->setText( tr( "&Start Tests!" ) );
243} 251}
244 252
245 253
246int BenchmarkInfo::textRendering( int seconds ) 254int BenchmarkInfo::textRendering( int seconds )
247{ 255{
248 QTime t; 256 QTime t;
249 t.start(); 257 t.start();
250 int stop = t.elapsed() + seconds * 1000; 258 int stop = t.elapsed() + seconds * 1000;
251 259
252 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; 260 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
253 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; 261 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
254 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; 262 int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
255 const QString text( "Opie Benchmark Test" ); 263 const QString text( "Opie Benchmark Test" );
256 264
257 int w = QApplication::desktop()->width(); 265 int w = QApplication::desktop()->width();
258 int h = QApplication::desktop()->height(); 266 int h = QApplication::desktop()->height();
259 267
260 srand( time( NULL ) ); 268 srand( time( NULL ) );
261 269
262 BenchmarkPaintWidget bpw; 270 BenchmarkPaintWidget bpw;
263 271
264 int loops = 0; 272 int loops = 0;
@@ -364,40 +372,40 @@ void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item
364 time.start(); 372 time.start();
365 if ( ::system( writeCommand ) == 0 ) 373 if ( ::system( writeCommand ) == 0 )
366 { 374 {
367 write = time.elapsed(); 375 write = time.elapsed();
368 } 376 }
369 else 377 else
370 { 378 {
371 item->setText( 1, tr( "error" ) ); 379 item->setText( 1, tr( "error" ) );
372 return; 380 return;
373 } 381 }
374 382
375 time.restart(); 383 time.restart();
376 if ( ::system( readCommand ) == 0 ) 384 if ( ::system( readCommand ) == 0 )
377 { 385 {
378 read = time.elapsed(); 386 read = time.elapsed();
379 } 387 }
380 else 388 else
381 { 389 {
382 item->setText( 1, tr( "error" ) ); 390 item->setText( 1, tr( "error" ) );
383 return; 391 return;
384 } 392 }
385 393
386 QFile::remove( filename ); 394 QFile::remove( filename );
387 double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 ); 395 double readSpeed = FILE_TEST_COUNT / ( read / 1000.0 );
388 QString readUnit = "kb/s"; 396 QString readUnit = "kB/s";
389 if ( readSpeed > 1024 ) 397 if ( readSpeed > 1024 )
390 { 398 {
391 readSpeed = readSpeed / 1024.0; 399 readSpeed = readSpeed / 1024.0;
392 readUnit = "mb/s"; 400 readUnit = "MB/s";
393 } 401 }
394 double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 ); 402 double writeSpeed = FILE_TEST_COUNT / ( write / 1000.0 );
395 QString writeUnit = "kb/s"; 403 QString writeUnit = "kb/s";
396 if ( writeSpeed > 1024 ) 404 if ( writeSpeed > 1024 )
397 { 405 {
398 writeSpeed = writeSpeed / 1024.0; 406 writeSpeed = writeSpeed / 1024.0;
399 writeUnit = "mb/s"; 407 writeUnit = "MBb/s";
400 } 408 }
401 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() ) );
402 item->setOn( false ); 410 item->setOn( false );
403} 411}