author | schurig <schurig> | 2004-09-10 06:10:18 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-10 06:10:18 (UTC) |
commit | 931d699302619ac6472aca4b893d8a8bd188f040 (patch) (unidiff) | |
tree | 01c9d454e79d88124714f1ec1ce07b9f08117d0a | |
parent | 317734f41201bf25fa3a1b38c2867bb9557053b9 (diff) | |
download | opie-931d699302619ac6472aca4b893d8a8bd188f040.zip opie-931d699302619ac6472aca4b893d8a8bd188f040.tar.gz opie-931d699302619ac6472aca4b893d8a8bd188f040.tar.bz2 |
disable SD and CF speed test on MNCI
change millibit to MegaByte (mb -> MB)
change kilobit to Kilobyte (kb -> kB)
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.h | 4 |
2 files changed, 18 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 | |||
@@ -1,403 +1,411 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** BenchmarkInfo | 2 | ** BenchmarkInfo |
3 | ** | 3 | ** |
4 | ** A benchmark for Qt/Embedded | 4 | ** A benchmark for Qt/Embedded |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> | 6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> |
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" | 19 | #include "benchmarkinfo.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <opie2/ostorageinfo.h> | 23 | #include <opie2/ostorageinfo.h> |
24 | #include <opie2/olistview.h> | 24 | #include <opie2/olistview.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/qpedecoration_qws.h> | 27 | #include <qpe/qpedecoration_qws.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | using namespace Opie::Ui; | 31 | using namespace Opie::Ui; |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qclipboard.h> | 34 | #include <qclipboard.h> |
35 | #include <qcolor.h> | 35 | #include <qcolor.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qdirectpainter_qws.h> | 37 | #include <qdirectpainter_qws.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qfiledialog.h> | 40 | #include <qfiledialog.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qpainter.h> | 43 | #include <qpainter.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qtimer.h> | 45 | #include <qtimer.h> |
46 | #include <qwhatsthis.h> | 46 | #include <qwhatsthis.h> |
47 | 47 | ||
48 | /* STD */ | 48 | /* STD */ |
49 | #include <time.h> | 49 | #include <time.h> |
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <math.h> | 52 | #include <math.h> |
53 | #if defined (__GNUC__) && (__GNUC__ < 3) | 53 | #if defined (__GNUC__) && (__GNUC__ < 3) |
54 | #define round qRound | 54 | #define round qRound |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | extern "C" | 57 | extern "C" |
58 | { | 58 | { |
59 | void BenchFFT( void ); | 59 | void BenchFFT( void ); |
60 | double dhry_main( int ); | 60 | double dhry_main( int ); |
61 | } | 61 | } |
62 | 62 | ||
63 | #define DHRYSTONE_RUNS 20000000 | 63 | #define DHRYSTONE_RUNS 20000000 |
64 | #define TEST_DURATION 3 | 64 | #define TEST_DURATION 3 |
65 | 65 | ||
66 | #define BUFF_SIZE 8192 | 66 | #define BUFF_SIZE 8192 |
67 | #define FILE_SIZE 1024 * 1024 // 1Mb | 67 | #define FILE_SIZE 1024 * 1024 // 1Mb |
68 | 68 | ||
69 | //=========================================================================== | 69 | //=========================================================================== |
70 | 70 | ||
71 | class BenchmarkPaintWidget : public QWidget | 71 | class BenchmarkPaintWidget : public QWidget |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 74 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
75 | { | 75 | { |
76 | resize( QApplication::desktop()->size() ); | 76 | resize( QApplication::desktop()->size() ); |
77 | show(); | 77 | show(); |
78 | p.begin( this ); | 78 | p.begin( this ); |
79 | }; | 79 | }; |
80 | 80 | ||
81 | ~BenchmarkPaintWidget() | 81 | ~BenchmarkPaintWidget() |
82 | { | 82 | { |
83 | p.end(); | 83 | p.end(); |
84 | hide(); | 84 | hide(); |
85 | }; | 85 | }; |
86 | 86 | ||
87 | QPainter p; | 87 | QPainter p; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | //=========================================================================== | 90 | //=========================================================================== |
91 | 91 | ||
92 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 92 | 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 ) ); |
159 | hb->addWidget( machineCombo, 2 ); | 163 | hb->addWidget( machineCombo, 2 ); |
160 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); | 164 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
161 | } | 165 | } |
162 | 166 | ||
163 | vb->addWidget( startButton, 2 ); | 167 | vb->addWidget( startButton, 2 ); |
164 | } | 168 | } |
165 | 169 | ||
166 | 170 | ||
167 | BenchmarkInfo::~BenchmarkInfo() | 171 | BenchmarkInfo::~BenchmarkInfo() |
168 | {} | 172 | {} |
169 | 173 | ||
170 | 174 | ||
171 | void BenchmarkInfo::machineActivated( int index ) | 175 | void 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 | ||
190 | void BenchmarkInfo::run() | 196 | void 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 | ||
246 | int BenchmarkInfo::textRendering( int seconds ) | 254 | int 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; |
265 | 273 | ||
266 | while ( t.elapsed() < stop ) | 274 | while ( t.elapsed() < stop ) |
267 | { | 275 | { |
268 | int k = rand() % 9; | 276 | int k = rand() % 9; |
269 | int s = rand() % 100; | 277 | int s = rand() % 100; |
270 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 278 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
271 | bpw.p.setFont( QFont( "Vera", s ) ); | 279 | bpw.p.setFont( QFont( "Vera", s ) ); |
272 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 280 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
273 | ++loops; | 281 | ++loops; |
274 | } | 282 | } |
275 | 283 | ||
276 | return loops * text.length(); | 284 | return loops * text.length(); |
277 | } | 285 | } |
278 | 286 | ||
279 | int BenchmarkInfo::gfxRendering( int seconds ) | 287 | int BenchmarkInfo::gfxRendering( int seconds ) |
280 | { | 288 | { |
281 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 289 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
282 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 290 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
283 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 291 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
284 | 292 | ||
285 | int w = QApplication::desktop()->width(); | 293 | int w = QApplication::desktop()->width(); |
286 | int h = QApplication::desktop()->height(); | 294 | int h = QApplication::desktop()->height(); |
287 | 295 | ||
288 | srand( time( NULL ) ); | 296 | srand( time( NULL ) ); |
289 | 297 | ||
290 | BenchmarkPaintWidget bpw; | 298 | BenchmarkPaintWidget bpw; |
291 | 299 | ||
292 | QTime t; | 300 | QTime t; |
293 | t.start(); | 301 | t.start(); |
294 | int stop = t.elapsed() + seconds*1000; | 302 | int stop = t.elapsed() + seconds*1000; |
295 | int loops = 0; | 303 | int loops = 0; |
296 | 304 | ||
297 | while ( t.elapsed() < stop ) | 305 | while ( t.elapsed() < stop ) |
298 | { | 306 | { |
299 | int k = rand() % 9; | 307 | int k = rand() % 9; |
300 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 308 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
301 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 309 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
302 | ++loops; | 310 | ++loops; |
303 | } | 311 | } |
304 | 312 | ||
305 | t.restart(); | 313 | t.restart(); |
306 | stop = t.elapsed() + seconds*1000; | 314 | stop = t.elapsed() + seconds*1000; |
307 | 315 | ||
308 | while ( t.elapsed() < stop ) | 316 | while ( t.elapsed() < stop ) |
309 | { | 317 | { |
310 | int k = rand() % 9; | 318 | int k = rand() % 9; |
311 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 319 | 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 ); | 320 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
313 | ++loops; | 321 | ++loops; |
314 | } | 322 | } |
315 | 323 | ||
316 | QBrush br1; | 324 | QBrush br1; |
317 | br1.setStyle( SolidPattern ); | 325 | br1.setStyle( SolidPattern ); |
318 | t.restart(); | 326 | t.restart(); |
319 | stop = t.elapsed() + seconds*1000; | 327 | stop = t.elapsed() + seconds*1000; |
320 | 328 | ||
321 | while ( t.elapsed() < stop ) | 329 | while ( t.elapsed() < stop ) |
322 | { | 330 | { |
323 | int k = rand() % 9; | 331 | int k = rand() % 9; |
324 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 332 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
325 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 333 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
326 | ++loops; | 334 | ++loops; |
327 | } | 335 | } |
328 | 336 | ||
329 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 337 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
330 | t.restart(); | 338 | t.restart(); |
331 | stop = t.elapsed() + seconds*1000; | 339 | stop = t.elapsed() + seconds*1000; |
332 | 340 | ||
333 | while ( t.elapsed() < stop ) | 341 | while ( t.elapsed() < stop ) |
334 | { | 342 | { |
335 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 343 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
336 | ++loops; | 344 | ++loops; |
337 | } | 345 | } |
338 | 346 | ||
339 | return loops; | 347 | return loops; |
340 | 348 | ||
341 | } | 349 | } |
342 | 350 | ||
343 | const unsigned int FILE_TEST_COUNT = 8000; | 351 | const unsigned int FILE_TEST_COUNT = 8000; |
344 | const unsigned int FILE_TEST_BLOCKSIZE = 1024; | 352 | const unsigned int FILE_TEST_BLOCKSIZE = 1024; |
345 | 353 | ||
346 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) | 354 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) |
347 | { | 355 | { |
348 | QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; | 356 | QString filename = fname == "/benchmarkFile.dat" ? QString( "/tmp/bla" ) : fname; |
349 | odebug << "performing file test on " << filename << oendl; | 357 | odebug << "performing file test on " << filename << oendl; |
350 | 358 | ||
351 | QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) | 359 | QString writeCommand = QString( "dd if=/dev/zero of=%1 count=%2 bs=%3 && sync" ).arg( filename ) |
352 | .arg( FILE_TEST_COUNT ) | 360 | .arg( FILE_TEST_COUNT ) |
353 | .arg( FILE_TEST_BLOCKSIZE ); | 361 | .arg( FILE_TEST_BLOCKSIZE ); |
354 | QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) | 362 | QString readCommand = QString( "dd if=%1 of=/dev/null count=%2 bs=%3").arg( filename ) |
355 | .arg( FILE_TEST_COUNT ) | 363 | .arg( FILE_TEST_COUNT ) |
356 | .arg( FILE_TEST_BLOCKSIZE ); | 364 | .arg( FILE_TEST_BLOCKSIZE ); |
357 | ::system( "sync" ); | 365 | ::system( "sync" ); |
358 | odebug << "performing file test on " << filename << oendl; | 366 | odebug << "performing file test on " << filename << oendl; |
359 | 367 | ||
360 | int write = 0; | 368 | int write = 0; |
361 | int read = 0; | 369 | int read = 0; |
362 | 370 | ||
363 | QTime time; | 371 | QTime time; |
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 | } |
diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h index 3b0a33c..4d61717 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.h +++ b/noncore/settings/sysinfo/benchmarkinfo.h | |||
@@ -1,67 +1,71 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** BenchmarkInfo | 2 | ** BenchmarkInfo |
3 | ** | 3 | ** |
4 | ** A benchmark for Qt/Embedded | 4 | ** A benchmark for Qt/Embedded |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> | 6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> |
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 <qwidget.h> | 19 | #include <qwidget.h> |
20 | #include <qdialog.h> | 20 | #include <qdialog.h> |
21 | #include <qdict.h> | 21 | #include <qdict.h> |
22 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
23 | 23 | ||
24 | class QClipboard; | 24 | class QClipboard; |
25 | class QComboBox; | 25 | class QComboBox; |
26 | namespace Opie {namespace Ui {class OCheckListItem;}} | 26 | namespace Opie {namespace Ui {class OCheckListItem;}} |
27 | class QPushButton; | 27 | class QPushButton; |
28 | namespace Opie {namespace Ui {class OListView;}} | 28 | namespace Opie {namespace Ui {class OListView;}} |
29 | 29 | ||
30 | class BenchmarkInfo : public QWidget | 30 | class BenchmarkInfo : public QWidget |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | 33 | ||
34 | public: | 34 | public: |
35 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); | 35 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); |
36 | ~BenchmarkInfo(); | 36 | ~BenchmarkInfo(); |
37 | 37 | ||
38 | Opie::Ui::OCheckListItem* test_alu; | 38 | Opie::Ui::OCheckListItem* test_alu; |
39 | Opie::Ui::OCheckListItem* test_fpu; | 39 | Opie::Ui::OCheckListItem* test_fpu; |
40 | Opie::Ui::OCheckListItem* test_txt; | 40 | Opie::Ui::OCheckListItem* test_txt; |
41 | Opie::Ui::OCheckListItem* test_gfx; | 41 | Opie::Ui::OCheckListItem* test_gfx; |
42 | Opie::Ui::OCheckListItem* test_ram; | 42 | Opie::Ui::OCheckListItem* test_ram; |
43 | #ifndef QT_QWS_RAMSES | ||
43 | Opie::Ui::OCheckListItem* test_sd; | 44 | Opie::Ui::OCheckListItem* test_sd; |
44 | Opie::Ui::OCheckListItem* test_cf; | 45 | Opie::Ui::OCheckListItem* test_cf; |
46 | #endif | ||
45 | 47 | ||
46 | bool main_rd; | 48 | bool main_rd; |
47 | bool main_wt; | 49 | bool main_wt; |
50 | #ifndef QT_QWS_RAMSES | ||
48 | bool sd_rd; | 51 | bool sd_rd; |
49 | bool sd_wt; | 52 | bool sd_wt; |
50 | bool cf_rd; | 53 | bool cf_rd; |
51 | bool cf_wt; | 54 | bool cf_wt; |
55 | #endif | ||
52 | 56 | ||
53 | QClipboard* clb; | 57 | QClipboard* clb; |
54 | QComboBox* machineCombo; | 58 | QComboBox* machineCombo; |
55 | Opie::Ui::OListView* tests; | 59 | Opie::Ui::OListView* tests; |
56 | QPushButton* startButton; | 60 | QPushButton* startButton; |
57 | QDict <QStringList> machines; | 61 | QDict <QStringList> machines; |
58 | 62 | ||
59 | int textRendering( int ); | 63 | int textRendering( int ); |
60 | int gfxRendering( int ); | 64 | int gfxRendering( int ); |
61 | void performFileTest( const QString& fname, Opie::Ui::OCheckListItem* item ); | 65 | void performFileTest( const QString& fname, Opie::Ui::OCheckListItem* item ); |
62 | 66 | ||
63 | private slots: | 67 | private slots: |
64 | void run(); | 68 | void run(); |
65 | void machineActivated( int ); | 69 | void machineActivated( int ); |
66 | }; | 70 | }; |
67 | 71 | ||