author | mickeyl <mickeyl> | 2004-03-05 21:37:50 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-05 21:37:50 (UTC) |
commit | 8851dc992ab535bde6cb417cafc44658953f495d (patch) (unidiff) | |
tree | 0a70bd4a768880e61c5af1ab142508c2bb81ecd0 /noncore/settings/sysinfo/benchmarkinfo.cpp | |
parent | b9d58b616102970872129b5bc2f55569910f5c03 (diff) | |
download | opie-8851dc992ab535bde6cb417cafc44658953f495d.zip opie-8851dc992ab535bde6cb417cafc44658953f495d.tar.gz opie-8851dc992ab535bde6cb417cafc44658953f495d.tar.bz2 |
use listview stuff from libopie2
miscellaneous cleanups
Diffstat (limited to 'noncore/settings/sysinfo/benchmarkinfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 2c68fd5..3c2c15f 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -7,58 +7,59 @@ | |||
7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> | 7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> |
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 | #include "benchmarkinfo.h" | ||
20 | |||
19 | /* OPIE */ | 21 | /* OPIE */ |
20 | #include <opie2/ostorageinfo.h> | 22 | #include <opie2/ostorageinfo.h> |
23 | #include <opie2/olistview.h> | ||
21 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpedecoration_qws.h> | 26 | #include <qpe/qpedecoration_qws.h> |
24 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
26 | 29 | ||
27 | /* QT */ | 30 | /* QT */ |
28 | #include <qclipboard.h> | 31 | #include <qclipboard.h> |
29 | #include <qcolor.h> | 32 | #include <qcolor.h> |
30 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
31 | #include <qdirectpainter_qws.h> | 34 | #include <qdirectpainter_qws.h> |
32 | #include <qfile.h> | 35 | #include <qfile.h> |
33 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
34 | #include <qfiledialog.h> | 37 | #include <qfiledialog.h> |
35 | #include <qlabel.h> | 38 | #include <qlabel.h> |
36 | #include <qlayout.h> | 39 | #include <qlayout.h> |
37 | #include <qpainter.h> | 40 | #include <qpainter.h> |
38 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
39 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwhatsthis.h> | ||
40 | 44 | ||
41 | /* STD */ | 45 | /* STD */ |
42 | #include <time.h> | 46 | #include <time.h> |
43 | #include <stdio.h> | 47 | #include <stdio.h> |
44 | #include <stdlib.h> | 48 | #include <stdlib.h> |
45 | #include <math.h> | 49 | #include <math.h> |
46 | #if defined (__GNUC__) && (__GNUC__ < 3) | 50 | #if defined (__GNUC__) && (__GNUC__ < 3) |
47 | extern double round(double); | 51 | extern double round(double); |
48 | #endif | 52 | #endif |
49 | 53 | ||
50 | |||
51 | #include "benchmarkinfo.h" | ||
52 | |||
53 | extern "C" | 54 | extern "C" |
54 | { | 55 | { |
55 | void BenchFFT( void ); | 56 | void BenchFFT( void ); |
56 | double dhry_main( int ); | 57 | double dhry_main( int ); |
57 | } | 58 | } |
58 | 59 | ||
59 | #define DHRYSTONE_RUNS 20000000 | 60 | #define DHRYSTONE_RUNS 20000000 |
60 | #define TEST_DURATION 3 | 61 | #define TEST_DURATION 3 |
61 | 62 | ||
62 | #define BUFF_SIZE 8192 | 63 | #define BUFF_SIZE 8192 |
63 | #define FILE_SIZE 1024 * 1024 // 1Mb | 64 | #define FILE_SIZE 1024 * 1024 // 1Mb |
64 | 65 | ||
@@ -86,64 +87,68 @@ class BenchmarkPaintWidget : public QWidget | |||
86 | //=========================================================================== | 87 | //=========================================================================== |
87 | 88 | ||
88 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 89 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
89 | : QWidget( parent, name, wFlags ) | 90 | : QWidget( parent, name, wFlags ) |
90 | { | 91 | { |
91 | 92 | ||
92 | setMinimumSize( 200, 150 ); | 93 | setMinimumSize( 200, 150 ); |
93 | 94 | ||
94 | QVBoxLayout* vb = new QVBoxLayout( this ); | 95 | QVBoxLayout* vb = new QVBoxLayout( this ); |
95 | vb->setSpacing( 4 ); | 96 | vb->setSpacing( 4 ); |
96 | vb->setMargin( 4 ); | 97 | vb->setMargin( 4 ); |
97 | 98 | ||
98 | tests = new QListView( this ); | 99 | tests = new OListView( this ); |
100 | QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " | ||
101 | "have been performed, and comparison values for one selected device. " | ||
102 | "Use the checkboxes to define which tests you want to perform." ) ); | ||
99 | tests->setMargin( 0 ); | 103 | tests->setMargin( 0 ); |
100 | tests->addColumn( tr( "Tests" ) ); | 104 | tests->addColumn( tr( "Tests" ) ); |
101 | tests->addColumn( tr( "Results" ) ); | 105 | tests->addColumn( tr( "Results" ) ); |
102 | tests->addColumn( tr( "Comparison" ) ); | 106 | tests->addColumn( tr( "Comparison" ) ); |
103 | tests->setShowSortIndicator( true ); | 107 | tests->setShowSortIndicator( true ); |
104 | 108 | ||
105 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); | 109 | test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); |
106 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); | 110 | test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); |
107 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); | 111 | test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); |
108 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); | 112 | test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); |
109 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); | 113 | test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); |
110 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); | 114 | test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); |
111 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); | 115 | test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); |
112 | 116 | ||
113 | test_alu->setText( 1, "n/a" ); | 117 | test_alu->setText( 1, "n/a" ); |
114 | test_fpu->setText( 1, "n/a" ); | 118 | test_fpu->setText( 1, "n/a" ); |
115 | test_txt->setText( 1, "n/a" ); | 119 | test_txt->setText( 1, "n/a" ); |
116 | test_gfx->setText( 1, "n/a" ); | 120 | test_gfx->setText( 1, "n/a" ); |
117 | test_ram->setText( 1, "n/a" ); | 121 | test_ram->setText( 1, "n/a" ); |
118 | test_sd->setText( 1, "n/a" ); | 122 | test_sd->setText( 1, "n/a" ); |
119 | test_cf->setText( 1, "n/a" ); | 123 | test_cf->setText( 1, "n/a" ); |
120 | 124 | ||
121 | test_alu->setText( 2, "n/a" ); | 125 | test_alu->setText( 2, "n/a" ); |
122 | test_fpu->setText( 2, "n/a" ); | 126 | test_fpu->setText( 2, "n/a" ); |
123 | test_txt->setText( 2, "n/a" ); | 127 | test_txt->setText( 2, "n/a" ); |
124 | test_gfx->setText( 2, "n/a" ); | 128 | test_gfx->setText( 2, "n/a" ); |
125 | test_ram->setText( 2, "n/a" ); | 129 | test_ram->setText( 2, "n/a" ); |
126 | test_sd->setText( 2, "n/a" ); | 130 | test_sd->setText( 2, "n/a" ); |
127 | test_cf->setText( 2, "n/a" ); | 131 | test_cf->setText( 2, "n/a" ); |
128 | 132 | ||
129 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 133 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
134 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); | ||
130 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 135 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
131 | |||
132 | vb->addWidget( tests, 2 ); | 136 | vb->addWidget( tests, 2 ); |
133 | 137 | ||
134 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 138 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
135 | if ( f.open( IO_ReadOnly ) ) | 139 | if ( f.open( IO_ReadOnly ) ) |
136 | { | 140 | { |
137 | machineCombo = new QComboBox( this ); | 141 | machineCombo = new QComboBox( this ); |
142 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); | ||
138 | 143 | ||
139 | QTextStream ts( &f ); | 144 | QTextStream ts( &f ); |
140 | while( !ts.eof() ) | 145 | while( !ts.eof() ) |
141 | { | 146 | { |
142 | QString machline = ts.readLine(); | 147 | QString machline = ts.readLine(); |
143 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 148 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
144 | QString resline = ts.readLine(); | 149 | QString resline = ts.readLine(); |
145 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 150 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
146 | machineCombo->insertItem( machline ); | 151 | machineCombo->insertItem( machline ); |
147 | } | 152 | } |
148 | 153 | ||
149 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 154 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
@@ -323,25 +328,25 @@ int BenchmarkInfo::gfxRendering( int seconds ) | |||
323 | stop = t.elapsed() + seconds*1000; | 328 | stop = t.elapsed() + seconds*1000; |
324 | 329 | ||
325 | while ( t.elapsed() < stop ) | 330 | while ( t.elapsed() < stop ) |
326 | { | 331 | { |
327 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 332 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
328 | ++loops; | 333 | ++loops; |
329 | } | 334 | } |
330 | 335 | ||
331 | return loops; | 336 | return loops; |
332 | 337 | ||
333 | } | 338 | } |
334 | 339 | ||
335 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) | 340 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) |
336 | { | 341 | { |
337 | QTime time; | 342 | QTime time; |
338 | time.start(); | 343 | time.start(); |
339 | if ( writeFile( fname ) && | 344 | if ( writeFile( fname ) && |
340 | readFile( fname ) ) | 345 | readFile( fname ) ) |
341 | { | 346 | { |
342 | QFile::remove( fname ); | 347 | QFile::remove( fname ); |
343 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); | 348 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); |
344 | item->setOn( false ); | 349 | item->setOn( false ); |
345 | } | 350 | } |
346 | else | 351 | else |
347 | { | 352 | { |