author | alwin <alwin> | 2004-03-02 19:15:03 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 19:15:03 (UTC) |
commit | 4e214ca53f618d2d848c6f281c545e1883bc52eb (patch) (unidiff) | |
tree | 0c276ac7e2578fc92ba10287d7a9cc90a2be3d64 | |
parent | d07327ddaab9214cde73081794dc13e33e1a1279 (diff) | |
download | opie-4e214ca53f618d2d848c6f281c545e1883bc52eb.zip opie-4e214ca53f618d2d848c6f281c545e1883bc52eb.tar.gz opie-4e214ca53f618d2d848c6f281c545e1883bc52eb.tar.bz2 |
hack so it compiles with gcc2 toolchain
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index d6ecec5..2c68fd5 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -1,429 +1,433 @@ | |||
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 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <opie2/ostorageinfo.h> | 20 | #include <opie2/ostorageinfo.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpedecoration_qws.h> | 23 | #include <qpe/qpedecoration_qws.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | 26 | ||
27 | /* QT */ | 27 | /* QT */ |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qcolor.h> | 29 | #include <qcolor.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qdirectpainter_qws.h> | 31 | #include <qdirectpainter_qws.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qfiledialog.h> | 34 | #include <qfiledialog.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | 40 | ||
41 | /* STD */ | 41 | /* STD */ |
42 | #include <time.h> | 42 | #include <time.h> |
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <math.h> | 45 | #include <math.h> |
46 | #if defined (__GNUC__) && (__GNUC__ < 3) | ||
47 | extern double round(double); | ||
48 | #endif | ||
49 | |||
46 | 50 | ||
47 | #include "benchmarkinfo.h" | 51 | #include "benchmarkinfo.h" |
48 | 52 | ||
49 | extern "C" | 53 | extern "C" |
50 | { | 54 | { |
51 | void BenchFFT( void ); | 55 | void BenchFFT( void ); |
52 | double dhry_main( int ); | 56 | double dhry_main( int ); |
53 | } | 57 | } |
54 | 58 | ||
55 | #define DHRYSTONE_RUNS 20000000 | 59 | #define DHRYSTONE_RUNS 20000000 |
56 | #define TEST_DURATION 3 | 60 | #define TEST_DURATION 3 |
57 | 61 | ||
58 | #define BUFF_SIZE 8192 | 62 | #define BUFF_SIZE 8192 |
59 | #define FILE_SIZE 1024 * 1024 // 1Mb | 63 | #define FILE_SIZE 1024 * 1024 // 1Mb |
60 | 64 | ||
61 | //=========================================================================== | 65 | //=========================================================================== |
62 | 66 | ||
63 | class BenchmarkPaintWidget : public QWidget | 67 | class BenchmarkPaintWidget : public QWidget |
64 | { | 68 | { |
65 | public: | 69 | public: |
66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 70 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
67 | { | 71 | { |
68 | resize( QApplication::desktop()->size() ); | 72 | resize( QApplication::desktop()->size() ); |
69 | show(); | 73 | show(); |
70 | p.begin( this ); | 74 | p.begin( this ); |
71 | }; | 75 | }; |
72 | 76 | ||
73 | ~BenchmarkPaintWidget() | 77 | ~BenchmarkPaintWidget() |
74 | { | 78 | { |
75 | p.end(); | 79 | p.end(); |
76 | hide(); | 80 | hide(); |
77 | }; | 81 | }; |
78 | 82 | ||
79 | QPainter p; | 83 | QPainter p; |
80 | }; | 84 | }; |
81 | 85 | ||
82 | //=========================================================================== | 86 | //=========================================================================== |
83 | 87 | ||
84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 88 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
85 | : QWidget( parent, name, wFlags ) | 89 | : QWidget( parent, name, wFlags ) |
86 | { | 90 | { |
87 | 91 | ||
88 | setMinimumSize( 200, 150 ); | 92 | setMinimumSize( 200, 150 ); |
89 | 93 | ||
90 | QVBoxLayout* vb = new QVBoxLayout( this ); | 94 | QVBoxLayout* vb = new QVBoxLayout( this ); |
91 | vb->setSpacing( 4 ); | 95 | vb->setSpacing( 4 ); |
92 | vb->setMargin( 4 ); | 96 | vb->setMargin( 4 ); |
93 | 97 | ||
94 | tests = new QListView( this ); | 98 | tests = new QListView( this ); |
95 | tests->setMargin( 0 ); | 99 | tests->setMargin( 0 ); |
96 | tests->addColumn( tr( "Tests" ) ); | 100 | tests->addColumn( tr( "Tests" ) ); |
97 | tests->addColumn( tr( "Results" ) ); | 101 | tests->addColumn( tr( "Results" ) ); |
98 | tests->addColumn( tr( "Comparison" ) ); | 102 | tests->addColumn( tr( "Comparison" ) ); |
99 | tests->setShowSortIndicator( true ); | 103 | tests->setShowSortIndicator( true ); |
100 | 104 | ||
101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); | 105 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); |
102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); | 106 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); |
103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); | 107 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); |
104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); | 108 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); |
105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); | 109 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); |
106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); | 110 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); |
107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); | 111 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); |
108 | 112 | ||
109 | test_alu->setText( 1, "n/a" ); | 113 | test_alu->setText( 1, "n/a" ); |
110 | test_fpu->setText( 1, "n/a" ); | 114 | test_fpu->setText( 1, "n/a" ); |
111 | test_txt->setText( 1, "n/a" ); | 115 | test_txt->setText( 1, "n/a" ); |
112 | test_gfx->setText( 1, "n/a" ); | 116 | test_gfx->setText( 1, "n/a" ); |
113 | test_ram->setText( 1, "n/a" ); | 117 | test_ram->setText( 1, "n/a" ); |
114 | test_sd->setText( 1, "n/a" ); | 118 | test_sd->setText( 1, "n/a" ); |
115 | test_cf->setText( 1, "n/a" ); | 119 | test_cf->setText( 1, "n/a" ); |
116 | 120 | ||
117 | test_alu->setText( 2, "n/a" ); | 121 | test_alu->setText( 2, "n/a" ); |
118 | test_fpu->setText( 2, "n/a" ); | 122 | test_fpu->setText( 2, "n/a" ); |
119 | test_txt->setText( 2, "n/a" ); | 123 | test_txt->setText( 2, "n/a" ); |
120 | test_gfx->setText( 2, "n/a" ); | 124 | test_gfx->setText( 2, "n/a" ); |
121 | test_ram->setText( 2, "n/a" ); | 125 | test_ram->setText( 2, "n/a" ); |
122 | test_sd->setText( 2, "n/a" ); | 126 | test_sd->setText( 2, "n/a" ); |
123 | test_cf->setText( 2, "n/a" ); | 127 | test_cf->setText( 2, "n/a" ); |
124 | 128 | ||
125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 129 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 130 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
127 | 131 | ||
128 | vb->addWidget( tests, 2 ); | 132 | vb->addWidget( tests, 2 ); |
129 | 133 | ||
130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 134 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
131 | if ( f.open( IO_ReadOnly ) ) | 135 | if ( f.open( IO_ReadOnly ) ) |
132 | { | 136 | { |
133 | machineCombo = new QComboBox( this ); | 137 | machineCombo = new QComboBox( this ); |
134 | 138 | ||
135 | QTextStream ts( &f ); | 139 | QTextStream ts( &f ); |
136 | while( !ts.eof() ) | 140 | while( !ts.eof() ) |
137 | { | 141 | { |
138 | QString machline = ts.readLine(); | 142 | QString machline = ts.readLine(); |
139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 143 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
140 | QString resline = ts.readLine(); | 144 | QString resline = ts.readLine(); |
141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 145 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
142 | machineCombo->insertItem( machline ); | 146 | machineCombo->insertItem( machline ); |
143 | } | 147 | } |
144 | 148 | ||
145 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 149 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 150 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
147 | hb->addWidget( machineCombo, 2 ); | 151 | hb->addWidget( machineCombo, 2 ); |
148 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); | 152 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
149 | } | 153 | } |
150 | 154 | ||
151 | vb->addWidget( startButton, 2 ); | 155 | vb->addWidget( startButton, 2 ); |
152 | } | 156 | } |
153 | 157 | ||
154 | 158 | ||
155 | BenchmarkInfo::~BenchmarkInfo() | 159 | BenchmarkInfo::~BenchmarkInfo() |
156 | {} | 160 | {} |
157 | 161 | ||
158 | 162 | ||
159 | void BenchmarkInfo::machineActivated( int index ) | 163 | void BenchmarkInfo::machineActivated( int index ) |
160 | { | 164 | { |
161 | QStringList* results = machines[ machineCombo->text( index ) ]; | 165 | QStringList* results = machines[ machineCombo->text( index ) ]; |
162 | if ( !results ) | 166 | if ( !results ) |
163 | { | 167 | { |
164 | qDebug( "sysinfo: no results available." ); | 168 | qDebug( "sysinfo: no results available." ); |
165 | return; | 169 | return; |
166 | } | 170 | } |
167 | QStringList::Iterator it = results->begin(); | 171 | QStringList::Iterator it = results->begin(); |
168 | test_alu->setText( 2, *(it++) ); | 172 | test_alu->setText( 2, *(it++) ); |
169 | test_fpu->setText( 2, *(it++) ); | 173 | test_fpu->setText( 2, *(it++) ); |
170 | test_txt->setText( 2, *(it++) ); | 174 | test_txt->setText( 2, *(it++) ); |
171 | test_gfx->setText( 2, *(it++) ); | 175 | test_gfx->setText( 2, *(it++) ); |
172 | test_ram->setText( 2, *(it++) ); | 176 | test_ram->setText( 2, *(it++) ); |
173 | test_sd->setText( 2, *(it++) ); | 177 | test_sd->setText( 2, *(it++) ); |
174 | test_cf->setText( 2, *(it++) ); | 178 | test_cf->setText( 2, *(it++) ); |
175 | } | 179 | } |
176 | 180 | ||
177 | 181 | ||
178 | void BenchmarkInfo::run() | 182 | void BenchmarkInfo::run() |
179 | { | 183 | { |
180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 184 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
181 | qApp->processEvents(); | 185 | qApp->processEvents(); |
182 | QTime t; | 186 | QTime t; |
183 | 187 | ||
184 | if ( test_alu->isOn() ) | 188 | if ( test_alu->isOn() ) |
185 | { | 189 | { |
186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 190 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 191 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
188 | test_alu->setOn( false ); | 192 | test_alu->setOn( false ); |
189 | } | 193 | } |
190 | 194 | ||
191 | if ( test_fpu->isOn() ) | 195 | if ( test_fpu->isOn() ) |
192 | { | 196 | { |
193 | t.start(); | 197 | t.start(); |
194 | BenchFFT(); | 198 | BenchFFT(); |
195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 199 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
196 | test_fpu->setOn( false ); | 200 | test_fpu->setOn( false ); |
197 | } | 201 | } |
198 | 202 | ||
199 | if ( test_txt->isOn() ) | 203 | if ( test_txt->isOn() ) |
200 | { | 204 | { |
201 | int value = textRendering( TEST_DURATION ); | 205 | int value = textRendering( TEST_DURATION ); |
202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); | 206 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
203 | test_txt->setOn( false ); | 207 | test_txt->setOn( false ); |
204 | } | 208 | } |
205 | 209 | ||
206 | if ( test_gfx->isOn() ) | 210 | if ( test_gfx->isOn() ) |
207 | { | 211 | { |
208 | int value = gfxRendering( TEST_DURATION ); | 212 | int value = gfxRendering( TEST_DURATION ); |
209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests | 213 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
210 | test_gfx->setOn( false ); | 214 | test_gfx->setOn( false ); |
211 | } | 215 | } |
212 | 216 | ||
213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 217 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
214 | { | 218 | { |
215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 219 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
216 | } | 220 | } |
217 | 221 | ||
218 | if ( test_cf->isOn() ) | 222 | if ( test_cf->isOn() ) |
219 | { | 223 | { |
220 | OStorageInfo storage; | 224 | OStorageInfo storage; |
221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 225 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
222 | } | 226 | } |
223 | 227 | ||
224 | if ( test_sd->isOn() ) | 228 | if ( test_sd->isOn() ) |
225 | { | 229 | { |
226 | OStorageInfo storage; | 230 | OStorageInfo storage; |
227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 231 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
228 | } | 232 | } |
229 | 233 | ||
230 | startButton->setText( tr( "&Start Tests!" ) ); | 234 | startButton->setText( tr( "&Start Tests!" ) ); |
231 | } | 235 | } |
232 | 236 | ||
233 | 237 | ||
234 | int BenchmarkInfo::textRendering( int seconds ) | 238 | int BenchmarkInfo::textRendering( int seconds ) |
235 | { | 239 | { |
236 | QTime t; | 240 | QTime t; |
237 | t.start(); | 241 | t.start(); |
238 | int stop = t.elapsed() + seconds * 1000; | 242 | int stop = t.elapsed() + seconds * 1000; |
239 | 243 | ||
240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 244 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 245 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 246 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
243 | const QString text( "Opie Benchmark Test" ); | 247 | const QString text( "Opie Benchmark Test" ); |
244 | 248 | ||
245 | int w = QApplication::desktop()->width(); | 249 | int w = QApplication::desktop()->width(); |
246 | int h = QApplication::desktop()->height(); | 250 | int h = QApplication::desktop()->height(); |
247 | 251 | ||
248 | srand( time( NULL ) ); | 252 | srand( time( NULL ) ); |
249 | 253 | ||
250 | BenchmarkPaintWidget bpw; | 254 | BenchmarkPaintWidget bpw; |
251 | 255 | ||
252 | int loops = 0; | 256 | int loops = 0; |
253 | 257 | ||
254 | while ( t.elapsed() < stop ) | 258 | while ( t.elapsed() < stop ) |
255 | { | 259 | { |
256 | int k = rand() % 9; | 260 | int k = rand() % 9; |
257 | int s = rand() % 100; | 261 | int s = rand() % 100; |
258 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 262 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
259 | bpw.p.setFont( QFont( "Vera", s ) ); | 263 | bpw.p.setFont( QFont( "Vera", s ) ); |
260 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 264 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
261 | ++loops; | 265 | ++loops; |
262 | } | 266 | } |
263 | 267 | ||
264 | return loops * text.length(); | 268 | return loops * text.length(); |
265 | } | 269 | } |
266 | 270 | ||
267 | int BenchmarkInfo::gfxRendering( int seconds ) | 271 | int BenchmarkInfo::gfxRendering( int seconds ) |
268 | { | 272 | { |
269 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 273 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
270 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 274 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
271 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 275 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
272 | 276 | ||
273 | int w = QApplication::desktop()->width(); | 277 | int w = QApplication::desktop()->width(); |
274 | int h = QApplication::desktop()->height(); | 278 | int h = QApplication::desktop()->height(); |
275 | 279 | ||
276 | srand( time( NULL ) ); | 280 | srand( time( NULL ) ); |
277 | 281 | ||
278 | BenchmarkPaintWidget bpw; | 282 | BenchmarkPaintWidget bpw; |
279 | 283 | ||
280 | QTime t; | 284 | QTime t; |
281 | t.start(); | 285 | t.start(); |
282 | int stop = t.elapsed() + seconds*1000; | 286 | int stop = t.elapsed() + seconds*1000; |
283 | int loops = 0; | 287 | int loops = 0; |
284 | 288 | ||
285 | while ( t.elapsed() < stop ) | 289 | while ( t.elapsed() < stop ) |
286 | { | 290 | { |
287 | int k = rand() % 9; | 291 | int k = rand() % 9; |
288 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 292 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
289 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 293 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
290 | ++loops; | 294 | ++loops; |
291 | } | 295 | } |
292 | 296 | ||
293 | t.restart(); | 297 | t.restart(); |
294 | stop = t.elapsed() + seconds*1000; | 298 | stop = t.elapsed() + seconds*1000; |
295 | 299 | ||
296 | while ( t.elapsed() < stop ) | 300 | while ( t.elapsed() < stop ) |
297 | { | 301 | { |
298 | int k = rand() % 9; | 302 | int k = rand() % 9; |
299 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 303 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
300 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 304 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
301 | ++loops; | 305 | ++loops; |
302 | } | 306 | } |
303 | 307 | ||
304 | QBrush br1; | 308 | QBrush br1; |
305 | br1.setStyle( SolidPattern ); | 309 | br1.setStyle( SolidPattern ); |
306 | t.restart(); | 310 | t.restart(); |
307 | stop = t.elapsed() + seconds*1000; | 311 | stop = t.elapsed() + seconds*1000; |
308 | 312 | ||
309 | while ( t.elapsed() < stop ) | 313 | while ( t.elapsed() < stop ) |
310 | { | 314 | { |
311 | int k = rand() % 9; | 315 | int k = rand() % 9; |
312 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 316 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
313 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 317 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
314 | ++loops; | 318 | ++loops; |
315 | } | 319 | } |
316 | 320 | ||
317 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 321 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
318 | t.restart(); | 322 | t.restart(); |
319 | stop = t.elapsed() + seconds*1000; | 323 | stop = t.elapsed() + seconds*1000; |
320 | 324 | ||
321 | while ( t.elapsed() < stop ) | 325 | while ( t.elapsed() < stop ) |
322 | { | 326 | { |
323 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 327 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
324 | ++loops; | 328 | ++loops; |
325 | } | 329 | } |
326 | 330 | ||
327 | return loops; | 331 | return loops; |
328 | 332 | ||
329 | } | 333 | } |
330 | 334 | ||
331 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) | 335 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) |
332 | { | 336 | { |
333 | QTime time; | 337 | QTime time; |
334 | time.start(); | 338 | time.start(); |
335 | if ( writeFile( fname ) && | 339 | if ( writeFile( fname ) && |
336 | readFile( fname ) ) | 340 | readFile( fname ) ) |
337 | { | 341 | { |
338 | QFile::remove( fname ); | 342 | QFile::remove( fname ); |
339 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); | 343 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); |
340 | item->setOn( false ); | 344 | item->setOn( false ); |
341 | } | 345 | } |
342 | else | 346 | else |
343 | { | 347 | { |
344 | item->setText( 1, tr( "error" ) ); | 348 | item->setText( 1, tr( "error" ) ); |
345 | } | 349 | } |
346 | } | 350 | } |
347 | 351 | ||
348 | char FileBuf[ BUFF_SIZE + 1 ]; | 352 | char FileBuf[ BUFF_SIZE + 1 ]; |
349 | 353 | ||
350 | bool BenchmarkInfo::writeFile( const QString& w_path ) | 354 | bool BenchmarkInfo::writeFile( const QString& w_path ) |
351 | { | 355 | { |
352 | int i; | 356 | int i; |
353 | int k; | 357 | int k; |
354 | int n; | 358 | int n; |
355 | int pos; | 359 | int pos; |
356 | int len; | 360 | int len; |
357 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 | 361 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 |
358 | 362 | ||
359 | 363 | ||
360 | // /*------------------------------------ | 364 | // /*------------------------------------ |
361 | int w_len; | 365 | int w_len; |
362 | 366 | ||
363 | QFile writeFile( w_path ); | 367 | QFile writeFile( w_path ); |
364 | srand( time( NULL ) ); | 368 | srand( time( NULL ) ); |
365 | 369 | ||
366 | for ( n = 0 ; n < 20 ; n++ ) | 370 | for ( n = 0 ; n < 20 ; n++ ) |
367 | { | 371 | { |
368 | if ( ! writeFile.open( IO_WriteOnly ) ) | 372 | if ( ! writeFile.open( IO_WriteOnly ) ) |
369 | { | 373 | { |
370 | writeFile.close(); | 374 | writeFile.close(); |
371 | writeFile.remove(); | 375 | writeFile.remove(); |
372 | return ( false ); | 376 | return ( false ); |
373 | } | 377 | } |
374 | // ------------------------------------------ sequential write | 378 | // ------------------------------------------ sequential write |
375 | for ( k = 0 ; k < 256 ; k++ ) | 379 | for ( k = 0 ; k < 256 ; k++ ) |
376 | { | 380 | { |
377 | n = rand() % 30; | 381 | n = rand() % 30; |
378 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); | 382 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); |
379 | } | 383 | } |
380 | 384 | ||
381 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 385 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
382 | { | 386 | { |
383 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); | 387 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); |
384 | if ( w_len != BUFF_SIZE ) | 388 | if ( w_len != BUFF_SIZE ) |
385 | { | 389 | { |
386 | writeFile.close(); | 390 | writeFile.close(); |
387 | writeFile.remove(); | 391 | writeFile.remove(); |
388 | return ( false ); | 392 | return ( false ); |
389 | } | 393 | } |
390 | writeFile.flush(); | 394 | writeFile.flush(); |
391 | } | 395 | } |
392 | // ------------------------------------------ random write | 396 | // ------------------------------------------ random write |
393 | for ( i = 0 ; i < 400 ; i++ ) | 397 | for ( i = 0 ; i < 400 ; i++ ) |
394 | { | 398 | { |
395 | len = rand() % 90 + 4000; | 399 | len = rand() % 90 + 4000; |
396 | for ( k = 0 ; k < 128 ; k++ ) | 400 | for ( k = 0 ; k < 128 ; k++ ) |
397 | { | 401 | { |
398 | n = rand() % 30; | 402 | n = rand() % 30; |
399 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); | 403 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); |
400 | } | 404 | } |
401 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); | 405 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); |
402 | 406 | ||
403 | writeFile.at( pos ); | 407 | writeFile.at( pos ); |
404 | w_len = writeFile.writeBlock( FileBuf, len ); | 408 | w_len = writeFile.writeBlock( FileBuf, len ); |
405 | if ( w_len != len ) | 409 | if ( w_len != len ) |
406 | { | 410 | { |
407 | writeFile.close(); | 411 | writeFile.close(); |
408 | writeFile.remove(); | 412 | writeFile.remove(); |
409 | return ( false ); | 413 | return ( false ); |
410 | } | 414 | } |
411 | writeFile.flush(); | 415 | writeFile.flush(); |
412 | } | 416 | } |
413 | writeFile.close(); | 417 | writeFile.close(); |
414 | } | 418 | } |
415 | return ( true ); | 419 | return ( true ); |
416 | 420 | ||
417 | } | 421 | } |
418 | 422 | ||
419 | 423 | ||
420 | bool BenchmarkInfo::readFile( const QString& r_path ) | 424 | bool BenchmarkInfo::readFile( const QString& r_path ) |
421 | { | 425 | { |
422 | int i; | 426 | int i; |
423 | int k; | 427 | int k; |
424 | int len; | 428 | int len; |
425 | int pos; | 429 | int pos; |
426 | int r_len; | 430 | int r_len; |
427 | 431 | ||
428 | QFile readFile( r_path ); | 432 | QFile readFile( r_path ); |
429 | srand( time( NULL ) ); | 433 | srand( time( NULL ) ); |