-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.h | 14 |
2 files changed, 48 insertions, 54 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 1d0b140..3dd4121 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -41,24 +41,27 @@ | |||
41 | #include <stdio.h> | 41 | #include <stdio.h> |
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <math.h> | 43 | #include <math.h> |
44 | 44 | ||
45 | #include "benchmarkinfo.h" | 45 | #include "benchmarkinfo.h" |
46 | 46 | ||
47 | extern "C" | 47 | extern "C" |
48 | { | 48 | { |
49 | void BenchFFT( void ); | 49 | void BenchFFT( void ); |
50 | double dhry_main( int ); | 50 | double dhry_main( int ); |
51 | } | 51 | } |
52 | 52 | ||
53 | #define DHRYSTONE_RUNS 20000000 | ||
54 | #define TEST_DURATION 3 | ||
55 | |||
53 | //=========================================================================== | 56 | //=========================================================================== |
54 | 57 | ||
55 | class BenchmarkPaintWidget : public QWidget | 58 | class BenchmarkPaintWidget : public QWidget |
56 | { | 59 | { |
57 | public: | 60 | public: |
58 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 61 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
59 | { | 62 | { |
60 | resize( QApplication::desktop()->size() ); | 63 | resize( QApplication::desktop()->size() ); |
61 | show(); | 64 | show(); |
62 | p.begin( this ); | 65 | p.begin( this ); |
63 | }; | 66 | }; |
64 | 67 | ||
@@ -116,49 +119,47 @@ BenchmarkInfo::~BenchmarkInfo() | |||
116 | {} | 119 | {} |
117 | 120 | ||
118 | 121 | ||
119 | void BenchmarkInfo::run() | 122 | void BenchmarkInfo::run() |
120 | { | 123 | { |
121 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 124 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
122 | qApp->processEvents(); | 125 | qApp->processEvents(); |
123 | QTime t; | 126 | QTime t; |
124 | 127 | ||
125 | if ( test_alu->isOn() ) | 128 | if ( test_alu->isOn() ) |
126 | { | 129 | { |
127 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 130 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
128 | test_alu->setText( 1, QString( "%1 DHRYS" ).arg( QString::number( d ) ) ); | 131 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
129 | test_alu->setOn( false ); | 132 | test_alu->setOn( false ); |
130 | } | 133 | } |
131 | 134 | ||
132 | if ( test_fpu->isOn() ) | 135 | if ( test_fpu->isOn() ) |
133 | { | 136 | { |
134 | t.start(); | 137 | t.start(); |
135 | BenchFFT(); | 138 | BenchFFT(); |
136 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 139 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
137 | test_fpu->setOn( false ); | 140 | test_fpu->setOn( false ); |
138 | } | 141 | } |
139 | 142 | ||
140 | if ( test_txt->isOn() ) | 143 | if ( test_txt->isOn() ) |
141 | { | 144 | { |
142 | t.start(); | 145 | int value = textRendering( TEST_DURATION ); |
143 | paintChar(); | 146 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
144 | test_txt->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | ||
145 | test_txt->setOn( false ); | 147 | test_txt->setOn( false ); |
146 | } | 148 | } |
147 | 149 | ||
148 | if ( test_gfx->isOn() ) | 150 | if ( test_gfx->isOn() ) |
149 | { | 151 | { |
150 | t.start(); | 152 | int value = gfxRendering( TEST_DURATION ); |
151 | paintLineRect(); | 153 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
152 | test_gfx->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | ||
153 | test_gfx->setOn( false ); | 154 | test_gfx->setOn( false ); |
154 | } | 155 | } |
155 | 156 | ||
156 | if ( test_ram->isOn() ) | 157 | if ( test_ram->isOn() ) |
157 | { | 158 | { |
158 | t.start(); | 159 | t.start(); |
159 | writeFile( "/tmp/benchmarkFile.dat" ); // /tmp is supposed to be in RAM on a PDA | 160 | writeFile( "/tmp/benchmarkFile.dat" ); // /tmp is supposed to be in RAM on a PDA |
160 | readFile( "/tmp/benchmarkFile.dat" ); | 161 | readFile( "/tmp/benchmarkFile.dat" ); |
161 | QFile::remove( "/tmp/benchmarkFile.dat" ); | 162 | QFile::remove( "/tmp/benchmarkFile.dat" ); |
162 | test_ram->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 163 | test_ram->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
163 | test_ram->setOn( false ); | 164 | test_ram->setOn( false ); |
164 | } | 165 | } |
@@ -181,116 +182,119 @@ void BenchmarkInfo::run() | |||
181 | 182 | ||
182 | if ( ( which_clipb ) && ( buf.length() > 0 ) ) | 183 | if ( ( which_clipb ) && ( buf.length() > 0 ) ) |
183 | { | 184 | { |
184 | clb = QApplication::clipboard(); | 185 | clb = QApplication::clipboard(); |
185 | clb->setText( dt_buf + buf ); | 186 | clb->setText( dt_buf + buf ); |
186 | } | 187 | } |
187 | */ | 188 | */ |
188 | 189 | ||
189 | startButton->setText( tr( "&Start Tests!" ) ); | 190 | startButton->setText( tr( "&Start Tests!" ) ); |
190 | } | 191 | } |
191 | 192 | ||
192 | 193 | ||
193 | void BenchmarkInfo::benchInteger() const | 194 | int BenchmarkInfo::textRendering( int seconds ) |
194 | { | 195 | { |
195 | long dummy = 1; | 196 | QTime t; |
196 | 197 | t.start(); | |
197 | for ( long i= 0 ; i < INT_TEST_ITERATIONS ; i++ ) | 198 | int stop = t.elapsed() + seconds * 1000; |
198 | { | ||
199 | for ( long j= 0 ; j < INT_TEST_ITERATIONS ; j++ ) | ||
200 | { | ||
201 | for( long k= 0 ; k < INT_TEST_ITERATIONS ; k++ ) | ||
202 | { | ||
203 | long xx = ( rand() % 1000 + 111 ) * 7 / 3 + 31; | ||
204 | long yy = ( rand() % 100 + 23 ) * 11 / 7 + 17; | ||
205 | long zz = ( rand() % 100 + 47 ) * 13 / 11 - 211; | ||
206 | dummy = xx * yy / zz; | ||
207 | dummy *= 23; | ||
208 | dummy += ( xx - yy + zz ); | ||
209 | dummy -= ( xx + yy - zz ); | ||
210 | dummy *= ( xx * zz * yy ); | ||
211 | dummy /= 1 + ( xx * yy * zz ); | ||
212 | } | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | |||
217 | 199 | ||
218 | void BenchmarkInfo::paintChar() | ||
219 | { | ||
220 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 200 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
221 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 201 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
222 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 202 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
223 | const QString text( "Opie Benchmark Test" ); | 203 | const QString text( "Opie Benchmark Test" ); |
224 | 204 | ||
225 | int w = QApplication::desktop()->width(); | 205 | int w = QApplication::desktop()->width(); |
226 | int h = QApplication::desktop()->height(); | 206 | int h = QApplication::desktop()->height(); |
227 | 207 | ||
228 | srand( time( NULL ) ); | 208 | srand( time( NULL ) ); |
229 | 209 | ||
230 | BenchmarkPaintWidget bpw; | 210 | BenchmarkPaintWidget bpw; |
231 | 211 | ||
232 | for ( int i = 0; i < CHAR_TEST_ITERATIONS; ++i ) | 212 | int loops = 0; |
213 | |||
214 | while ( t.elapsed() < stop ) | ||
233 | { | 215 | { |
234 | int k = rand() % 9; | 216 | int k = rand() % 9; |
217 | int s = rand() % 100; | ||
235 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 218 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
236 | bpw.p.setFont( QFont( "Vera", k*10 ) ); | 219 | bpw.p.setFont( QFont( "Vera", s ) ); |
237 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 220 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
221 | ++loops; | ||
238 | } | 222 | } |
223 | |||
224 | return loops * text.length(); | ||
239 | } | 225 | } |
240 | 226 | ||
241 | void BenchmarkInfo::paintLineRect() | 227 | int BenchmarkInfo::gfxRendering( int seconds ) |
242 | { | 228 | { |
243 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 229 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
244 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 230 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
245 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 231 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
246 | 232 | ||
247 | int w = QApplication::desktop()->width(); | 233 | int w = QApplication::desktop()->width(); |
248 | int h = QApplication::desktop()->height(); | 234 | int h = QApplication::desktop()->height(); |
249 | 235 | ||
250 | srand( time( NULL ) ); | 236 | srand( time( NULL ) ); |
251 | 237 | ||
252 | BenchmarkPaintWidget bpw; | 238 | BenchmarkPaintWidget bpw; |
253 | 239 | ||
254 | for ( int i = 0; i < DRAW_TEST_ITERATIONS*3; ++i ) | 240 | QTime t; |
241 | t.start(); | ||
242 | int stop = t.elapsed() + seconds*1000; | ||
243 | int loops = 0; | ||
244 | |||
245 | while ( t.elapsed() < stop ) | ||
255 | { | 246 | { |
256 | int k = rand() % 9; | 247 | int k = rand() % 9; |
257 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 248 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
258 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 249 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
250 | ++loops; | ||
259 | } | 251 | } |
260 | 252 | ||
261 | for ( int i = 0; i < DRAW_TEST_ITERATIONS; ++i ) | 253 | t.restart(); |
254 | stop = t.elapsed() + seconds*1000; | ||
255 | |||
256 | while ( t.elapsed() < stop ) | ||
262 | { | 257 | { |
263 | int k = rand() % 9; | 258 | int k = rand() % 9; |
264 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 259 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
265 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 260 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
261 | ++loops; | ||
266 | } | 262 | } |
267 | 263 | ||
268 | QBrush br1; | 264 | QBrush br1; |
269 | br1.setStyle( SolidPattern ); | 265 | br1.setStyle( SolidPattern ); |
270 | 266 | t.restart(); | |
271 | for ( int i = 0; i < DRAW_TEST_ITERATIONS*2; ++i ) | 267 | stop = t.elapsed() + seconds*1000; |
268 | |||
269 | while ( t.elapsed() < stop ) | ||
272 | { | 270 | { |
273 | int k = rand() % 9; | 271 | int k = rand() % 9; |
274 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 272 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
275 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 273 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
274 | ++loops; | ||
276 | } | 275 | } |
277 | 276 | ||
278 | QPixmap p = Resource::loadPixmap( "pattern" ); | 277 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
279 | for ( int i = 0; i < DRAW_TEST_ITERATIONS; ++i ) | 278 | t.restart(); |
279 | stop = t.elapsed() + seconds*1000; | ||
280 | |||
281 | while ( t.elapsed() < stop ) | ||
280 | { | 282 | { |
281 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 283 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
284 | ++loops; | ||
282 | } | 285 | } |
283 | 286 | ||
284 | 287 | return loops; | |
288 | |||
285 | } | 289 | } |
286 | 290 | ||
287 | // ********************************************************************** | 291 | // ********************************************************************** |
288 | // Read & Write | 292 | // Read & Write |
289 | // v2.0.0 | 293 | // v2.0.0 |
290 | // ********************************************************************** | 294 | // ********************************************************************** |
291 | #define BUFF_SIZE 8192 | 295 | #define BUFF_SIZE 8192 |
292 | #define FILE_SIZE 1024 * 1024 // 1Mb | 296 | #define FILE_SIZE 1024 * 1024 // 1Mb |
293 | 297 | ||
294 | char FileBuf[ BUFF_SIZE + 1 ]; | 298 | char FileBuf[ BUFF_SIZE + 1 ]; |
295 | 299 | ||
296 | bool BenchmarkInfo::writeFile( const QString& w_path ) | 300 | bool BenchmarkInfo::writeFile( const QString& w_path ) |
diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h index 2d994b4..55398eb 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.h +++ b/noncore/settings/sysinfo/benchmarkinfo.h | |||
@@ -15,33 +15,24 @@ | |||
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 | //#define INT_TEST_ITERATIONS 50 | ||
28 | //#define CHAR_TEST_ITERATIONS 15000 | ||
29 | //#define DRAW_TEST_ITERATIONS 5000 | ||
30 | |||
31 | #define INT_TEST_ITERATIONS 50 | ||
32 | #define DHRYSTONE_RUNS 20000000 | ||
33 | #define CHAR_TEST_ITERATIONS 15000 | ||
34 | #define DRAW_TEST_ITERATIONS 5000 | ||
35 | |||
36 | class BenchmarkInfo : public QWidget | 27 | class BenchmarkInfo : public QWidget |
37 | { | 28 | { |
38 | Q_OBJECT | 29 | Q_OBJECT |
39 | 30 | ||
40 | public: | 31 | public: |
41 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); | 32 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); |
42 | ~BenchmarkInfo(); | 33 | ~BenchmarkInfo(); |
43 | 34 | ||
44 | QCheckListItem* test_alu; | 35 | QCheckListItem* test_alu; |
45 | QCheckListItem* test_fpu; | 36 | QCheckListItem* test_fpu; |
46 | QCheckListItem* test_txt; | 37 | QCheckListItem* test_txt; |
47 | QCheckListItem* test_gfx; | 38 | QCheckListItem* test_gfx; |
@@ -52,22 +43,21 @@ public: | |||
52 | bool main_rd; | 43 | bool main_rd; |
53 | bool main_wt; | 44 | bool main_wt; |
54 | bool sd_rd; | 45 | bool sd_rd; |
55 | bool sd_wt; | 46 | bool sd_wt; |
56 | bool cf_rd; | 47 | bool cf_rd; |
57 | bool cf_wt; | 48 | bool cf_wt; |
58 | 49 | ||
59 | QClipboard* clb; | 50 | QClipboard* clb; |
60 | 51 | ||
61 | QListView* tests; | 52 | QListView* tests; |
62 | QPushButton* startButton; | 53 | QPushButton* startButton; |
63 | 54 | ||
64 | void benchInteger() const; | 55 | int textRendering( int ); |
65 | void paintChar(); | 56 | int gfxRendering( int ); |
66 | void paintLineRect(); | ||
67 | bool writeFile( const QString& ); | 57 | bool writeFile( const QString& ); |
68 | bool readFile( const QString& ); | 58 | bool readFile( const QString& ); |
69 | 59 | ||
70 | private slots: | 60 | private slots: |
71 | void run(); | 61 | void run(); |
72 | 62 | ||
73 | }; | 63 | }; |