author | mickeyl <mickeyl> | 2004-02-27 23:12:01 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-27 23:12:01 (UTC) |
commit | 99d1378aeaad7613b820d5c3b55911c77a01d7c5 (patch) (unidiff) | |
tree | 4d509df258c29f19f7d1502db185fd1b02339cba | |
parent | ef5dd6301fee8abe99320d3151f4aae1b4e9e776 (diff) | |
download | opie-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 ;)
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 96 | ||||
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.h | 7 |
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 | |||
@@ -1,458 +1,416 @@ | |||
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 <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> |
32 | #include <qapplication.h> | 33 | #include <qapplication.h> |
33 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
34 | #include <qclipboard.h> | 35 | #include <qclipboard.h> |
35 | #include <qtimer.h> | 36 | #include <qtimer.h> |
36 | #include <qcolor.h> | 37 | #include <qcolor.h> |
37 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
38 | 39 | ||
39 | /* STD */ | 40 | /* STD */ |
40 | #include <time.h> | 41 | #include <time.h> |
41 | #include <stdio.h> | 42 | #include <stdio.h> |
42 | #include <stdlib.h> | 43 | #include <stdlib.h> |
43 | #include <math.h> | 44 | #include <math.h> |
44 | 45 | ||
45 | #include "benchmarkinfo.h" | 46 | #include "benchmarkinfo.h" |
46 | 47 | ||
47 | extern "C" | 48 | extern "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 | ||
58 | class BenchmarkPaintWidget : public QWidget | 62 | class 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 | ||
68 | ~BenchmarkPaintWidget() | 72 | ~BenchmarkPaintWidget() |
69 | { | 73 | { |
70 | p.end(); | 74 | p.end(); |
71 | hide(); | 75 | hide(); |
72 | }; | 76 | }; |
73 | 77 | ||
74 | QPainter p; | 78 | QPainter p; |
75 | }; | 79 | }; |
76 | 80 | ||
77 | //=========================================================================== | 81 | //=========================================================================== |
78 | 82 | ||
79 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 83 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
80 | : QWidget( parent, name, wFlags ) | 84 | : QWidget( parent, name, wFlags ) |
81 | { | 85 | { |
82 | 86 | ||
83 | setMinimumSize( 200, 150 ); | 87 | setMinimumSize( 200, 150 ); |
84 | 88 | ||
85 | QVBoxLayout* vb = new QVBoxLayout( this ); | 89 | QVBoxLayout* vb = new QVBoxLayout( this ); |
86 | vb->setSpacing( 4 ); | 90 | vb->setSpacing( 4 ); |
87 | vb->setMargin( 4 ); | 91 | vb->setMargin( 4 ); |
88 | 92 | ||
89 | tests = new QListView( this ); | 93 | tests = new QListView( this ); |
90 | tests->setMargin( 1 ); | 94 | tests->setMargin( 1 ); |
91 | tests->addColumn( "Tests" ); | 95 | tests->addColumn( "Tests" ); |
92 | tests->addColumn( "Results" ); | 96 | tests->addColumn( "Results" ); |
93 | tests->setShowSortIndicator( true ); | 97 | tests->setShowSortIndicator( true ); |
94 | 98 | ||
95 | test_alu = new QCheckListItem( tests, "1: Integer Arithmetic ", QCheckListItem::CheckBox ); | 99 | test_alu = new QCheckListItem( tests, "1: Integer Arithmetic ", QCheckListItem::CheckBox ); |
96 | test_alu->setText( 1, "n/a" ); | 100 | test_alu->setText( 1, "n/a" ); |
97 | test_fpu = new QCheckListItem( tests, "2: Floating Point Unit ", QCheckListItem::CheckBox ); | 101 | test_fpu = new QCheckListItem( tests, "2: Floating Point Unit ", QCheckListItem::CheckBox ); |
98 | test_fpu->setText( 1, "n/a" ); | 102 | test_fpu->setText( 1, "n/a" ); |
99 | test_txt = new QCheckListItem( tests, "3: Text Rendering ", QCheckListItem::CheckBox ); | 103 | test_txt = new QCheckListItem( tests, "3: Text Rendering ", QCheckListItem::CheckBox ); |
100 | test_txt->setText( 1, "n/a" ); | 104 | test_txt->setText( 1, "n/a" ); |
101 | test_gfx = new QCheckListItem( tests, "4: Gfx Rendering ", QCheckListItem::CheckBox ); | 105 | test_gfx = new QCheckListItem( tests, "4: Gfx Rendering ", QCheckListItem::CheckBox ); |
102 | test_gfx->setText( 1, "n/a" ); | 106 | test_gfx->setText( 1, "n/a" ); |
103 | test_ram = new QCheckListItem( tests, "5: RAM Performance ", QCheckListItem::CheckBox ); | 107 | test_ram = new QCheckListItem( tests, "5: RAM Performance ", QCheckListItem::CheckBox ); |
104 | test_ram->setText( 1, "n/a" ); | 108 | test_ram->setText( 1, "n/a" ); |
105 | test_sd = new QCheckListItem( tests, "6: SD Card Performance ", QCheckListItem::CheckBox ); | 109 | test_sd = new QCheckListItem( tests, "6: SD Card Performance ", QCheckListItem::CheckBox ); |
106 | test_sd->setText( 1, "n/a" ); | 110 | test_sd->setText( 1, "n/a" ); |
107 | test_cf = new QCheckListItem( tests, "7: CF Card Performance ", QCheckListItem::CheckBox ); | 111 | test_cf = new QCheckListItem( tests, "7: CF Card Performance ", QCheckListItem::CheckBox ); |
108 | test_cf->setText( 1, "n/a" ); | 112 | test_cf->setText( 1, "n/a" ); |
109 | 113 | ||
110 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 114 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
111 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 115 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
112 | 116 | ||
113 | vb->addWidget( tests, 2 ); | 117 | vb->addWidget( tests, 2 ); |
114 | vb->addWidget( startButton ); | 118 | vb->addWidget( startButton ); |
115 | } | 119 | } |
116 | 120 | ||
117 | 121 | ||
118 | BenchmarkInfo::~BenchmarkInfo() | 122 | BenchmarkInfo::~BenchmarkInfo() |
119 | {} | 123 | {} |
120 | 124 | ||
121 | 125 | ||
122 | void BenchmarkInfo::run() | 126 | void BenchmarkInfo::run() |
123 | { | 127 | { |
124 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 128 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
125 | qApp->processEvents(); | 129 | qApp->processEvents(); |
126 | QTime t; | 130 | QTime t; |
127 | 131 | ||
128 | if ( test_alu->isOn() ) | 132 | if ( test_alu->isOn() ) |
129 | { | 133 | { |
130 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 134 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
131 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 135 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
132 | test_alu->setOn( false ); | 136 | test_alu->setOn( false ); |
133 | } | 137 | } |
134 | 138 | ||
135 | if ( test_fpu->isOn() ) | 139 | if ( test_fpu->isOn() ) |
136 | { | 140 | { |
137 | t.start(); | 141 | t.start(); |
138 | BenchFFT(); | 142 | BenchFFT(); |
139 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 143 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
140 | test_fpu->setOn( false ); | 144 | test_fpu->setOn( false ); |
141 | } | 145 | } |
142 | 146 | ||
143 | if ( test_txt->isOn() ) | 147 | if ( test_txt->isOn() ) |
144 | { | 148 | { |
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 | ||
194 | int BenchmarkInfo::textRendering( int seconds ) | 182 | int 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 }; |
202 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 190 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
203 | const QString text( "Opie Benchmark Test" ); | 191 | const QString text( "Opie Benchmark Test" ); |
204 | 192 | ||
205 | int w = QApplication::desktop()->width(); | 193 | int w = QApplication::desktop()->width(); |
206 | int h = QApplication::desktop()->height(); | 194 | int h = QApplication::desktop()->height(); |
207 | 195 | ||
208 | srand( time( NULL ) ); | 196 | srand( time( NULL ) ); |
209 | 197 | ||
210 | BenchmarkPaintWidget bpw; | 198 | BenchmarkPaintWidget bpw; |
211 | 199 | ||
212 | int loops = 0; | 200 | int loops = 0; |
213 | 201 | ||
214 | while ( t.elapsed() < stop ) | 202 | while ( t.elapsed() < stop ) |
215 | { | 203 | { |
216 | int k = rand() % 9; | 204 | int k = rand() % 9; |
217 | int s = rand() % 100; | 205 | int s = rand() % 100; |
218 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 206 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
219 | bpw.p.setFont( QFont( "Vera", s ) ); | 207 | bpw.p.setFont( QFont( "Vera", s ) ); |
220 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 208 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
221 | ++loops; | 209 | ++loops; |
222 | } | 210 | } |
223 | 211 | ||
224 | return loops * text.length(); | 212 | return loops * text.length(); |
225 | } | 213 | } |
226 | 214 | ||
227 | int BenchmarkInfo::gfxRendering( int seconds ) | 215 | int BenchmarkInfo::gfxRendering( int seconds ) |
228 | { | 216 | { |
229 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 217 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
230 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 218 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
231 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 219 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
232 | 220 | ||
233 | int w = QApplication::desktop()->width(); | 221 | int w = QApplication::desktop()->width(); |
234 | int h = QApplication::desktop()->height(); | 222 | int h = QApplication::desktop()->height(); |
235 | 223 | ||
236 | srand( time( NULL ) ); | 224 | srand( time( NULL ) ); |
237 | 225 | ||
238 | BenchmarkPaintWidget bpw; | 226 | BenchmarkPaintWidget bpw; |
239 | 227 | ||
240 | QTime t; | 228 | QTime t; |
241 | t.start(); | 229 | t.start(); |
242 | int stop = t.elapsed() + seconds*1000; | 230 | int stop = t.elapsed() + seconds*1000; |
243 | int loops = 0; | 231 | int loops = 0; |
244 | 232 | ||
245 | while ( t.elapsed() < stop ) | 233 | while ( t.elapsed() < stop ) |
246 | { | 234 | { |
247 | int k = rand() % 9; | 235 | int k = rand() % 9; |
248 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 236 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
249 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 237 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
250 | ++loops; | 238 | ++loops; |
251 | } | 239 | } |
252 | 240 | ||
253 | t.restart(); | 241 | t.restart(); |
254 | stop = t.elapsed() + seconds*1000; | 242 | stop = t.elapsed() + seconds*1000; |
255 | 243 | ||
256 | while ( t.elapsed() < stop ) | 244 | while ( t.elapsed() < stop ) |
257 | { | 245 | { |
258 | int k = rand() % 9; | 246 | int k = rand() % 9; |
259 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 247 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
260 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 248 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
261 | ++loops; | 249 | ++loops; |
262 | } | 250 | } |
263 | 251 | ||
264 | QBrush br1; | 252 | QBrush br1; |
265 | br1.setStyle( SolidPattern ); | 253 | br1.setStyle( SolidPattern ); |
266 | t.restart(); | 254 | t.restart(); |
267 | stop = t.elapsed() + seconds*1000; | 255 | stop = t.elapsed() + seconds*1000; |
268 | 256 | ||
269 | while ( t.elapsed() < stop ) | 257 | while ( t.elapsed() < stop ) |
270 | { | 258 | { |
271 | int k = rand() % 9; | 259 | int k = rand() % 9; |
272 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 260 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
273 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 261 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
274 | ++loops; | 262 | ++loops; |
275 | } | 263 | } |
276 | 264 | ||
277 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 265 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
278 | t.restart(); | 266 | t.restart(); |
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 | // ********************************************************************** | 279 | void 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 | ||
298 | char FileBuf[ BUFF_SIZE + 1 ]; | 296 | char FileBuf[ BUFF_SIZE + 1 ]; |
299 | 297 | ||
300 | bool BenchmarkInfo::writeFile( const QString& w_path ) | 298 | bool 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 | ||
309 | 307 | ||
310 | // /*------------------------------------ | 308 | // /*------------------------------------ |
311 | int w_len; | 309 | int w_len; |
312 | 310 | ||
313 | QFile writeFile( w_path ); | 311 | QFile writeFile( w_path ); |
314 | srand( time( NULL ) ); | 312 | srand( time( NULL ) ); |
315 | 313 | ||
316 | for ( n = 0 ; n < 20 ; n++ ) | 314 | for ( n = 0 ; n < 20 ; n++ ) |
317 | { | 315 | { |
318 | if ( ! writeFile.open( IO_WriteOnly ) ) | 316 | if ( ! writeFile.open( IO_WriteOnly ) ) |
319 | { | 317 | { |
320 | writeFile.close(); | 318 | writeFile.close(); |
321 | writeFile.remove(); | 319 | writeFile.remove(); |
322 | return ( false ); | 320 | return ( false ); |
323 | } | 321 | } |
324 | // ------------------------------------------ sequential write | 322 | // ------------------------------------------ sequential write |
325 | for ( k = 0 ; k < 256 ; k++ ) | 323 | for ( k = 0 ; k < 256 ; k++ ) |
326 | { | 324 | { |
327 | n = rand() % 30; | 325 | n = rand() % 30; |
328 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); | 326 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); |
329 | } | 327 | } |
330 | 328 | ||
331 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 329 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
332 | { | 330 | { |
333 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); | 331 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); |
334 | if ( w_len != BUFF_SIZE ) | 332 | if ( w_len != BUFF_SIZE ) |
335 | { | 333 | { |
336 | writeFile.close(); | 334 | writeFile.close(); |
337 | writeFile.remove(); | 335 | writeFile.remove(); |
338 | return ( false ); | 336 | return ( false ); |
339 | } | 337 | } |
340 | writeFile.flush(); | 338 | writeFile.flush(); |
341 | } | 339 | } |
342 | // ------------------------------------------ random write | 340 | // ------------------------------------------ random write |
343 | for ( i = 0 ; i < 400 ; i++ ) | 341 | for ( i = 0 ; i < 400 ; i++ ) |
344 | { | 342 | { |
345 | len = rand() % 90 + 4000; | 343 | len = rand() % 90 + 4000; |
346 | for ( k = 0 ; k < 128 ; k++ ) | 344 | for ( k = 0 ; k < 128 ; k++ ) |
347 | { | 345 | { |
348 | n = rand() % 30; | 346 | n = rand() % 30; |
349 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); | 347 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); |
350 | } | 348 | } |
351 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); | 349 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); |
352 | 350 | ||
353 | writeFile.at( pos ); | 351 | writeFile.at( pos ); |
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 | ||
410 | bool BenchmarkInfo::readFile( const QString& r_path ) | 368 | bool 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 ); |
419 | srand( time( NULL ) ); | 377 | srand( time( NULL ) ); |
420 | 378 | ||
421 | for ( k = 0 ; k < 200 ; k++ ) | 379 | for ( k = 0 ; k < 200 ; k++ ) |
422 | { | 380 | { |
423 | if ( ! readFile.open( IO_ReadOnly ) ) | 381 | if ( ! readFile.open( IO_ReadOnly ) ) |
424 | { | 382 | { |
425 | readFile.remove(); | 383 | readFile.remove(); |
426 | return ( false ); | 384 | return ( false ); |
427 | } | 385 | } |
428 | // ------------------------------------------ sequential read | 386 | // ------------------------------------------ sequential read |
429 | readFile.at( 0 ); | 387 | readFile.at( 0 ); |
430 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 388 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
431 | { | 389 | { |
432 | readFile.at( i * BUFF_SIZE ); | 390 | readFile.at( i * BUFF_SIZE ); |
433 | r_len = readFile.readBlock( FileBuf, BUFF_SIZE ); | 391 | r_len = readFile.readBlock( FileBuf, BUFF_SIZE ); |
434 | if ( r_len != BUFF_SIZE ) | 392 | if ( r_len != BUFF_SIZE ) |
435 | { | 393 | { |
436 | readFile.close(); | 394 | readFile.close(); |
437 | readFile.remove(); | 395 | readFile.remove(); |
438 | return ( false ); | 396 | return ( false ); |
439 | } | 397 | } |
440 | } | 398 | } |
441 | // ------------------------------------------ random read | 399 | // ------------------------------------------ random read |
442 | for ( i = 0 ; i < 1000 ; i++ ) | 400 | for ( i = 0 ; i < 1000 ; i++ ) |
443 | { | 401 | { |
444 | len = rand() % 120 + 8; | 402 | len = rand() % 120 + 8; |
445 | pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE ); | 403 | pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE ); |
446 | readFile.at( pos ); | 404 | readFile.at( pos ); |
447 | r_len = readFile.readBlock( FileBuf, len ); | 405 | r_len = readFile.readBlock( FileBuf, len ); |
448 | if ( r_len != len ) | 406 | if ( r_len != len ) |
449 | { | 407 | { |
450 | readFile.close(); | 408 | readFile.close(); |
451 | readFile.remove(); | 409 | readFile.remove(); |
452 | return ( false ); | 410 | return ( false ); |
453 | } | 411 | } |
454 | } | 412 | } |
455 | readFile.close(); | 413 | readFile.close(); |
456 | } | 414 | } |
457 | return ( true ); | 415 | return ( true ); |
458 | } | 416 | } |
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 | |||
@@ -1,63 +1,64 @@ | |||
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 | 21 | ||
22 | class QClipboard; | 22 | class QClipboard; |
23 | class QCheckListItem; | 23 | class QCheckListItem; |
24 | class QPushButton; | 24 | class QPushButton; |
25 | class QListView; | 25 | class QListView; |
26 | 26 | ||
27 | class BenchmarkInfo : public QWidget | 27 | class BenchmarkInfo : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | 30 | ||
31 | public: | 31 | public: |
32 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); | 32 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); |
33 | ~BenchmarkInfo(); | 33 | ~BenchmarkInfo(); |
34 | 34 | ||
35 | QCheckListItem* test_alu; | 35 | QCheckListItem* test_alu; |
36 | QCheckListItem* test_fpu; | 36 | QCheckListItem* test_fpu; |
37 | QCheckListItem* test_txt; | 37 | QCheckListItem* test_txt; |
38 | QCheckListItem* test_gfx; | 38 | QCheckListItem* test_gfx; |
39 | QCheckListItem* test_ram; | 39 | QCheckListItem* test_ram; |
40 | QCheckListItem* test_sd; | 40 | QCheckListItem* test_sd; |
41 | QCheckListItem* test_cf; | 41 | QCheckListItem* test_cf; |
42 | 42 | ||
43 | bool main_rd; | 43 | bool main_rd; |
44 | bool main_wt; | 44 | bool main_wt; |
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 | ||
60 | private slots: | 59 | private slots: |
60 | bool writeFile( const QString& ); | ||
61 | bool readFile( const QString& ); | ||
61 | void run(); | 62 | void run(); |
62 | |||
63 | }; | 63 | }; |
64 | |||