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 | |||
@@ -131,259 +131,273 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | |||
131 | test_gfx->setText( 2, "n/a" ); | 131 | test_gfx->setText( 2, "n/a" ); |
132 | test_ram->setText( 2, "n/a" ); | 132 | test_ram->setText( 2, "n/a" ); |
133 | test_sd->setText( 2, "n/a" ); | 133 | test_sd->setText( 2, "n/a" ); |
134 | test_cf->setText( 2, "n/a" ); | 134 | test_cf->setText( 2, "n/a" ); |
135 | 135 | ||
136 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 136 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
137 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); | 137 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); |
138 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 138 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
139 | vb->addWidget( tests, 2 ); | 139 | vb->addWidget( tests, 2 ); |
140 | 140 | ||
141 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 141 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
142 | if ( f.open( IO_ReadOnly ) ) | 142 | if ( f.open( IO_ReadOnly ) ) |
143 | { | 143 | { |
144 | machineCombo = new QComboBox( this ); | 144 | machineCombo = new QComboBox( this ); |
145 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); | 145 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); |
146 | 146 | ||
147 | QTextStream ts( &f ); | 147 | QTextStream ts( &f ); |
148 | while( !ts.eof() ) | 148 | while( !ts.eof() ) |
149 | { | 149 | { |
150 | QString machline = ts.readLine(); | 150 | QString machline = ts.readLine(); |
151 | odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; | 151 | odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; |
152 | QString resline = ts.readLine(); | 152 | QString resline = ts.readLine(); |
153 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 153 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
154 | machineCombo->insertItem( machline ); | 154 | machineCombo->insertItem( machline ); |
155 | } | 155 | } |
156 | 156 | ||
157 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 157 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
158 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 158 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
159 | hb->addWidget( machineCombo, 2 ); | 159 | hb->addWidget( machineCombo, 2 ); |
160 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); | 160 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
161 | } | 161 | } |
162 | 162 | ||
163 | vb->addWidget( startButton, 2 ); | 163 | vb->addWidget( startButton, 2 ); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | BenchmarkInfo::~BenchmarkInfo() | 167 | BenchmarkInfo::~BenchmarkInfo() |
168 | {} | 168 | {} |
169 | 169 | ||
170 | 170 | ||
171 | void BenchmarkInfo::machineActivated( int index ) | 171 | void BenchmarkInfo::machineActivated( int index ) |
172 | { | 172 | { |
173 | QStringList* results = machines[ machineCombo->text( index ) ]; | 173 | QStringList* results = machines[ machineCombo->text( index ) ]; |
174 | if ( !results ) | 174 | if ( !results ) |
175 | { | 175 | { |
176 | odebug << "sysinfo: no results available." << oendl; | 176 | odebug << "sysinfo: no results available." << oendl; |
177 | return; | 177 | return; |
178 | } | 178 | } |
179 | QStringList::Iterator it = results->begin(); | 179 | QStringList::Iterator it = results->begin(); |
180 | test_alu->setText( 2, *(it++) ); | 180 | test_alu->setText( 2, *(it++) ); |
181 | test_fpu->setText( 2, *(it++) ); | 181 | test_fpu->setText( 2, *(it++) ); |
182 | test_txt->setText( 2, *(it++) ); | 182 | test_txt->setText( 2, *(it++) ); |
183 | test_gfx->setText( 2, *(it++) ); | 183 | test_gfx->setText( 2, *(it++) ); |
184 | test_ram->setText( 2, *(it++) ); | 184 | test_ram->setText( 2, *(it++) ); |
185 | test_sd->setText( 2, *(it++) ); | 185 | test_sd->setText( 2, *(it++) ); |
186 | test_cf->setText( 2, *(it++) ); | 186 | test_cf->setText( 2, *(it++) ); |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | void BenchmarkInfo::run() | 190 | void BenchmarkInfo::run() |
191 | { | 191 | { |
192 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 192 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
193 | qApp->processEvents(); | 193 | qApp->processEvents(); |
194 | QTime t; | 194 | QTime t; |
195 | 195 | ||
196 | if ( test_alu->isOn() ) | 196 | if ( test_alu->isOn() ) |
197 | { | 197 | { |
198 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 198 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
199 | test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); | 199 | test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); |
200 | test_alu->setOn( false ); | 200 | test_alu->setOn( false ); |
201 | } | 201 | } |
202 | 202 | ||
203 | if ( test_fpu->isOn() ) | 203 | if ( test_fpu->isOn() ) |
204 | { | 204 | { |
205 | t.start(); | 205 | t.start(); |
206 | BenchFFT(); | 206 | BenchFFT(); |
207 | test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );; | 207 | test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );; |
208 | test_fpu->setOn( false ); | 208 | test_fpu->setOn( false ); |
209 | } | 209 | } |
210 | 210 | ||
211 | if ( test_txt->isOn() ) | 211 | if ( test_txt->isOn() ) |
212 | { | 212 | { |
213 | int value = textRendering( TEST_DURATION ); | 213 | int value = textRendering( TEST_DURATION ); |
214 | test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); | 214 | test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); |
215 | test_txt->setOn( false ); | 215 | test_txt->setOn( false ); |
216 | } | 216 | } |
217 | 217 | ||
218 | if ( test_gfx->isOn() ) | 218 | if ( test_gfx->isOn() ) |
219 | { | 219 | { |
220 | int value = gfxRendering( TEST_DURATION ); | 220 | int value = gfxRendering( TEST_DURATION ); |
221 | test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4 / TEST_DURATION ) ); // 4 tests | 221 | test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4 / TEST_DURATION ) ); // 4 tests |
222 | test_gfx->setOn( false ); | 222 | test_gfx->setOn( false ); |
223 | } | 223 | } |
224 | 224 | ||
225 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 225 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
226 | { | 226 | { |
227 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 227 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
228 | } | 228 | } |
229 | 229 | ||
230 | if ( test_cf->isOn() ) | 230 | if ( test_cf->isOn() ) |
231 | { | 231 | { |
232 | OStorageInfo storage; | 232 | OStorageInfo storage; |
233 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 233 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
234 | } | 234 | } |
235 | 235 | ||
236 | if ( test_sd->isOn() ) | 236 | if ( test_sd->isOn() ) |
237 | { | 237 | { |
238 | OStorageInfo storage; | 238 | OStorageInfo storage; |
239 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 239 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
240 | } | 240 | } |
241 | 241 | ||
242 | startButton->setText( tr( "&Start Tests!" ) ); | 242 | startButton->setText( tr( "&Start Tests!" ) ); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | int BenchmarkInfo::textRendering( int seconds ) | 246 | int BenchmarkInfo::textRendering( int seconds ) |
247 | { | 247 | { |
248 | QTime t; | 248 | QTime t; |
249 | t.start(); | 249 | t.start(); |
250 | int stop = t.elapsed() + seconds * 1000; | 250 | int stop = t.elapsed() + seconds * 1000; |
251 | 251 | ||
252 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 252 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
253 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 253 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
254 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 254 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
255 | const QString text( "Opie Benchmark Test" ); | 255 | const QString text( "Opie Benchmark Test" ); |
256 | 256 | ||
257 | int w = QApplication::desktop()->width(); | 257 | int w = QApplication::desktop()->width(); |
258 | int h = QApplication::desktop()->height(); | 258 | int h = QApplication::desktop()->height(); |
259 | 259 | ||
260 | srand( time( NULL ) ); | 260 | srand( time( NULL ) ); |
261 | 261 | ||
262 | BenchmarkPaintWidget bpw; | 262 | BenchmarkPaintWidget bpw; |
263 | 263 | ||
264 | int loops = 0; | 264 | int loops = 0; |
265 | 265 | ||
266 | while ( t.elapsed() < stop ) | 266 | while ( t.elapsed() < stop ) |
267 | { | 267 | { |
268 | int k = rand() % 9; | 268 | int k = rand() % 9; |
269 | int s = rand() % 100; | 269 | int s = rand() % 100; |
270 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 270 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
271 | bpw.p.setFont( QFont( "Vera", s ) ); | 271 | bpw.p.setFont( QFont( "Vera", s ) ); |
272 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 272 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
273 | ++loops; | 273 | ++loops; |
274 | } | 274 | } |
275 | 275 | ||
276 | return loops * text.length(); | 276 | return loops * text.length(); |
277 | } | 277 | } |
278 | 278 | ||
279 | int BenchmarkInfo::gfxRendering( int seconds ) | 279 | int BenchmarkInfo::gfxRendering( int seconds ) |
280 | { | 280 | { |
281 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 281 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
282 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 282 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
283 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 283 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
284 | 284 | ||
285 | int w = QApplication::desktop()->width(); | 285 | int w = QApplication::desktop()->width(); |
286 | int h = QApplication::desktop()->height(); | 286 | int h = QApplication::desktop()->height(); |
287 | 287 | ||
288 | srand( time( NULL ) ); | 288 | srand( time( NULL ) ); |
289 | 289 | ||
290 | BenchmarkPaintWidget bpw; | 290 | BenchmarkPaintWidget bpw; |
291 | 291 | ||
292 | QTime t; | 292 | QTime t; |
293 | t.start(); | 293 | t.start(); |
294 | int stop = t.elapsed() + seconds*1000; | 294 | int stop = t.elapsed() + seconds*1000; |
295 | int loops = 0; | 295 | int loops = 0; |
296 | 296 | ||
297 | while ( t.elapsed() < stop ) | 297 | while ( t.elapsed() < stop ) |
298 | { | 298 | { |
299 | int k = rand() % 9; | 299 | int k = rand() % 9; |
300 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 300 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
301 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 301 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
302 | ++loops; | 302 | ++loops; |
303 | } | 303 | } |
304 | 304 | ||
305 | t.restart(); | 305 | t.restart(); |
306 | stop = t.elapsed() + seconds*1000; | 306 | stop = t.elapsed() + seconds*1000; |
307 | 307 | ||
308 | while ( t.elapsed() < stop ) | 308 | while ( t.elapsed() < stop ) |
309 | { | 309 | { |
310 | int k = rand() % 9; | 310 | int k = rand() % 9; |
311 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 311 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
312 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 312 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
313 | ++loops; | 313 | ++loops; |
314 | } | 314 | } |
315 | 315 | ||
316 | QBrush br1; | 316 | QBrush br1; |
317 | br1.setStyle( SolidPattern ); | 317 | br1.setStyle( SolidPattern ); |
318 | t.restart(); | 318 | t.restart(); |
319 | stop = t.elapsed() + seconds*1000; | 319 | stop = t.elapsed() + seconds*1000; |
320 | 320 | ||
321 | while ( t.elapsed() < stop ) | 321 | while ( t.elapsed() < stop ) |
322 | { | 322 | { |
323 | int k = rand() % 9; | 323 | int k = rand() % 9; |
324 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 324 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
325 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 325 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
326 | ++loops; | 326 | ++loops; |
327 | } | 327 | } |
328 | 328 | ||
329 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 329 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
330 | t.restart(); | 330 | t.restart(); |
331 | stop = t.elapsed() + seconds*1000; | 331 | stop = t.elapsed() + seconds*1000; |
332 | 332 | ||
333 | while ( t.elapsed() < stop ) | 333 | while ( t.elapsed() < stop ) |
334 | { | 334 | { |
335 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 335 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
336 | ++loops; | 336 | ++loops; |
337 | } | 337 | } |
338 | 338 | ||
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 | } |