summaryrefslogtreecommitdiff
path: root/noncore
authormickeyl <mickeyl>2004-02-27 23:12:01 (UTC)
committer mickeyl <mickeyl>2004-02-27 23:12:01 (UTC)
commit99d1378aeaad7613b820d5c3b55911c77a01d7c5 (patch) (unidiff)
tree4d509df258c29f19f7d1502db185fd1b02339cba /noncore
parentef5dd6301fee8abe99320d3151f4aae1b4e9e776 (diff)
downloadopie-99d1378aeaad7613b820d5c3b55911c77a01d7c5.zip
opie-99d1378aeaad7613b820d5c3b55911c77a01d7c5.tar.gz
opie-99d1378aeaad7613b820d5c3b55911c77a01d7c5.tar.bz2
ram,cf and sd seem to work now. didn't test on a PDA yet though ;)
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp96
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.h7
2 files changed, 31 insertions, 72 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 3dd4121..69d8229 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -8,24 +8,25 @@
8** 8**
9** This file may be distributed and/or modified under the terms of the 9** This file may be distributed and/or modified under the terms of the
10** GNU General Public License version 2 as published by the Free Software 10** GNU General Public License version 2 as published by the Free Software
11** Foundation and appearing in the file LICENSE.GPL included in the 11** Foundation and appearing in the file LICENSE.GPL included in the
12** packaging of this file. 12** packaging of this file.
13** 13**
14** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 14** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
15** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 15** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16** 16**
17**********************************************************************/ 17**********************************************************************/
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/ostorageinfo.h>
20#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
21#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpedecoration_qws.h> 23#include <qpe/qpedecoration_qws.h>
23#include <qpe/resource.h> 24#include <qpe/resource.h>
24#include <qpe/config.h> 25#include <qpe/config.h>
25 26
26/* QT */ 27/* QT */
27#include <qlayout.h> 28#include <qlayout.h>
28#include <qfiledialog.h> 29#include <qfiledialog.h>
29#include <qlabel.h> 30#include <qlabel.h>
30#include <qpainter.h> 31#include <qpainter.h>
31#include <qdirectpainter_qws.h> 32#include <qdirectpainter_qws.h>
@@ -44,24 +45,27 @@
44 45
45#include "benchmarkinfo.h" 46#include "benchmarkinfo.h"
46 47
47extern "C" 48extern "C"
48{ 49{
49 void BenchFFT( void ); 50 void BenchFFT( void );
50 double dhry_main( int ); 51 double dhry_main( int );
51} 52}
52 53
53#define DHRYSTONE_RUNS 20000000 54#define DHRYSTONE_RUNS 20000000
54#define TEST_DURATION 3 55#define TEST_DURATION 3
55 56
57#define BUFF_SIZE 8192
58#define FILE_SIZE 1024 * 1024 // 1Mb
59
56//=========================================================================== 60//===========================================================================
57 61
58class BenchmarkPaintWidget : public QWidget 62class BenchmarkPaintWidget : public QWidget
59{ 63{
60 public: 64 public:
61 BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) 65 BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever )
62 { 66 {
63 resize( QApplication::desktop()->size() ); 67 resize( QApplication::desktop()->size() );
64 show(); 68 show();
65 p.begin( this ); 69 p.begin( this );
66 }; 70 };
67 71
@@ -145,57 +149,41 @@ void BenchmarkInfo::run()
145 int value = textRendering( TEST_DURATION ); 149 int value = textRendering( TEST_DURATION );
146 test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); 150 test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) );
147 test_txt->setOn( false ); 151 test_txt->setOn( false );
148 } 152 }
149 153
150 if ( test_gfx->isOn() ) 154 if ( test_gfx->isOn() )
151 { 155 {
152 int value = gfxRendering( TEST_DURATION ); 156 int value = gfxRendering( TEST_DURATION );
153 test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests 157 test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests
154 test_gfx->setOn( false ); 158 test_gfx->setOn( false );
155 } 159 }
156 160
157 if ( test_ram->isOn() ) 161 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA
158 { 162 {
159 t.start(); 163 performFileTest( "/tmp/benchmarkFile.dat", test_ram );
160 writeFile( "/tmp/benchmarkFile.dat" ); // /tmp is supposed to be in RAM on a PDA
161 readFile( "/tmp/benchmarkFile.dat" );
162 QFile::remove( "/tmp/benchmarkFile.dat" );
163 test_ram->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) );
164 test_ram->setOn( false );
165 } 164 }
166/* 165
167 if ( test_cf->isOn() ) 166 if ( test_cf->isOn() )
168 { 167 {
169 t.start(); 168 OStorageInfo storage;
170 benchInteger(); 169 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
171 test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) );
172 test_alu->setOn( false );
173 } 170 }
174 171
175 if ( test_sd->isOn() ) 172 if ( test_sd->isOn() )
176 { 173 {
177 t.start(); 174 OStorageInfo storage;
178 benchInteger(); 175 performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd );
179 test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) );
180 test_alu->setOn( false );
181 } 176 }
182 177
183 if ( ( which_clipb ) && ( buf.length() > 0 ) )
184 {
185 clb = QApplication::clipboard();
186 clb->setText( dt_buf + buf );
187 }
188 */
189
190 startButton->setText( tr( "&Start Tests!" ) ); 178 startButton->setText( tr( "&Start Tests!" ) );
191} 179}
192 180
193 181
194int BenchmarkInfo::textRendering( int seconds ) 182int BenchmarkInfo::textRendering( int seconds )
195{ 183{
196 QTime t; 184 QTime t;
197 t.start(); 185 t.start();
198 int stop = t.elapsed() + seconds * 1000; 186 int stop = t.elapsed() + seconds * 1000;
199 187
200 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; 188 int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
201 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; 189 int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
@@ -279,30 +267,40 @@ int BenchmarkInfo::gfxRendering( int seconds )
279 stop = t.elapsed() + seconds*1000; 267 stop = t.elapsed() + seconds*1000;
280 268
281 while ( t.elapsed() < stop ) 269 while ( t.elapsed() < stop )
282 { 270 {
283 bpw.p.drawPixmap( rand()%w, rand()%h, p ); 271 bpw.p.drawPixmap( rand()%w, rand()%h, p );
284 ++loops; 272 ++loops;
285 } 273 }
286 274
287 return loops; 275 return loops;
288 276
289} 277}
290 278
291// ********************************************************************** 279void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item )
292// Read & Write 280{
293// v2.0.0 281 QTime time;
294// ********************************************************************** 282 time.start();
295#define BUFF_SIZE 8192 283 if ( writeFile( fname ) &&
296#define FILE_SIZE 1024 * 1024 // 1Mb 284 readFile( fname ) )
285 {
286 QFile::remove( fname );
287 item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) );
288 item->setOn( false );
289 }
290 else
291 {
292 item->setText( 1, tr( "error" ) );
293 }
294}
297 295
298char FileBuf[ BUFF_SIZE + 1 ]; 296char FileBuf[ BUFF_SIZE + 1 ];
299 297
300bool BenchmarkInfo::writeFile( const QString& w_path ) 298bool BenchmarkInfo::writeFile( const QString& w_path )
301{ 299{
302 int i; 300 int i;
303 int k; 301 int k;
304 int n; 302 int n;
305 int pos; 303 int pos;
306 int len; 304 int len;
307 char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 305 char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62
308 306
@@ -354,65 +352,25 @@ bool BenchmarkInfo::writeFile( const QString& w_path )
354 w_len = writeFile.writeBlock( FileBuf, len ); 352 w_len = writeFile.writeBlock( FileBuf, len );
355 if ( w_len != len ) 353 if ( w_len != len )
356 { 354 {
357 writeFile.close(); 355 writeFile.close();
358 writeFile.remove(); 356 writeFile.remove();
359 return ( false ); 357 return ( false );
360 } 358 }
361 writeFile.flush(); 359 writeFile.flush();
362 } 360 }
363 writeFile.close(); 361 writeFile.close();
364 } 362 }
365 return ( true ); 363 return ( true );
366 // ------------------------------------*/
367
368 /* ----------------------------------
369 srand( time( NULL ) );
370 364
371 FILE *fp;
372
373 for( n= 0 ; n < 40 ; n++ )
374 {
375 if (( fp = fopen( w_path, "wt" )) == NULL )
376 return( false );
377 memset( FileBuf, '\0', BUFF_SIZE+1 );
378 // ------------------------------------------ sequential write
379 for( i= 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ )
380 {
381 for( k= 0 ; k < 128 ; k++ )
382 {
383 n = rand() % 30;
384 memcpy( &FileBuf[k*8], &data[n], 32 );
385 }
386 fputs( FileBuf, fp );
387 }
388 // ------------------------------------------ random write
389 for( i= 0 ; i < 300 ; i++ )
390 {
391 memset( FileBuf, '\0', 130 );
392 len = rand() % 120 + 8;
393 for( k= 0 ; k < 16 ; k++ )
394 {
395 n = rand() % 54;
396 memcpy( &FileBuf[k*8], &data[n], 8 );
397 }
398 pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE );
399
400 fseek( fp, pos, SEEK_SET );
401 fputs( FileBuf, fp );
402 }
403 fclose( fp );
404 }
405 return( true );
406 -------------------------------------*/
407} 365}
408 366
409 367
410bool BenchmarkInfo::readFile( const QString& r_path ) 368bool BenchmarkInfo::readFile( const QString& r_path )
411{ 369{
412 int i; 370 int i;
413 int k; 371 int k;
414 int len; 372 int len;
415 int pos; 373 int pos;
416 int r_len; 374 int r_len;
417 375
418 QFile readFile( r_path ); 376 QFile readFile( r_path );
diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h
index 55398eb..3c5ca37 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.h
+++ b/noncore/settings/sysinfo/benchmarkinfo.h
@@ -45,19 +45,20 @@ public:
45 bool sd_rd; 45 bool sd_rd;
46 bool sd_wt; 46 bool sd_wt;
47 bool cf_rd; 47 bool cf_rd;
48 bool cf_wt; 48 bool cf_wt;
49 49
50 QClipboard* clb; 50 QClipboard* clb;
51 51
52 QListView* tests; 52 QListView* tests;
53 QPushButton* startButton; 53 QPushButton* startButton;
54 54
55 int textRendering( int ); 55 int textRendering( int );
56 int gfxRendering( int ); 56 int gfxRendering( int );
57 bool writeFile( const QString& ); 57 void performFileTest( const QString& fname, QCheckListItem* item );
58 bool readFile( const QString& );
59 58
60private slots: 59private slots:
60 bool writeFile( const QString& );
61 bool readFile( const QString& );
61 void run(); 62 void run();
62
63}; 63};
64