summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp84
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.h14
2 files changed, 46 insertions, 52 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
@@ -29,48 +29,51 @@
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpainter.h> 30#include <qpainter.h>
31#include <qdirectpainter_qws.h> 31#include <qdirectpainter_qws.h>
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qclipboard.h> 34#include <qclipboard.h>
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qcolor.h> 36#include <qcolor.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38 38
39/* STD */ 39/* STD */
40#include <time.h> 40#include <time.h>
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
47extern "C" 47extern "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
55class BenchmarkPaintWidget : public QWidget 58class 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
65 ~BenchmarkPaintWidget() 68 ~BenchmarkPaintWidget()
66 { 69 {
67 p.end(); 70 p.end();
68 hide(); 71 hide();
69 }; 72 };
70 73
71 QPainter p; 74 QPainter p;
72}; 75};
73 76
74//=========================================================================== 77//===========================================================================
75 78
76BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) 79BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
@@ -104,204 +107,205 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
104 test_cf = new QCheckListItem( tests, "7: CF Card Performance ", QCheckListItem::CheckBox ); 107 test_cf = new QCheckListItem( tests, "7: CF Card Performance ", QCheckListItem::CheckBox );
105 test_cf->setText( 1, "n/a" ); 108 test_cf->setText( 1, "n/a" );
106 109
107 startButton = new QPushButton( tr( "&Start Tests!" ), this ); 110 startButton = new QPushButton( tr( "&Start Tests!" ), this );
108 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); 111 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
109 112
110 vb->addWidget( tests, 2 ); 113 vb->addWidget( tests, 2 );
111 vb->addWidget( startButton ); 114 vb->addWidget( startButton );
112} 115}
113 116
114 117
115BenchmarkInfo::~BenchmarkInfo() 118BenchmarkInfo::~BenchmarkInfo()
116{} 119{}
117 120
118 121
119void BenchmarkInfo::run() 122void 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 }
165/* 166/*
166 if ( test_cf->isOn() ) 167 if ( test_cf->isOn() )
167 { 168 {
168 t.start(); 169 t.start();
169 benchInteger(); 170 benchInteger();
170 test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); 171 test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) );
171 test_alu->setOn( false ); 172 test_alu->setOn( false );
172 } 173 }
173 174
174 if ( test_sd->isOn() ) 175 if ( test_sd->isOn() )
175 { 176 {
176 t.start(); 177 t.start();
177 benchInteger(); 178 benchInteger();
178 test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); 179 test_alu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) );
179 test_alu->setOn( false ); 180 test_alu->setOn( false );
180 } 181 }
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
193void BenchmarkInfo::benchInteger() const 194int BenchmarkInfo::textRendering( int seconds )
194{
195 long dummy = 1;
196
197 for ( long i= 0 ; i < INT_TEST_ITERATIONS ; i++ )
198 {
199 for ( long j= 0 ; j < INT_TEST_ITERATIONS ; j++ )
200 { 195 {
201 for( long k= 0 ; k < INT_TEST_ITERATIONS ; k++ ) 196 QTime t;
202 { 197 t.start();
203 long xx = ( rand() % 1000 + 111 ) * 7 / 3 + 31; 198 int stop = t.elapsed() + seconds * 1000;
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
218void 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
241void BenchmarkInfo::paintLineRect() 227int 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 );
266 t.restart();
267 stop = t.elapsed() + seconds*1000;
270 268
271 for ( int i = 0; i < DRAW_TEST_ITERATIONS*2; ++i ) 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
287 return loops;
284 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
294char FileBuf[ BUFF_SIZE + 1 ]; 298char FileBuf[ BUFF_SIZE + 1 ];
295 299
296bool BenchmarkInfo::writeFile( const QString& w_path ) 300bool BenchmarkInfo::writeFile( const QString& w_path )
297{ 301{
298 int i; 302 int i;
299 int k; 303 int k;
300 int n; 304 int n;
301 int pos; 305 int pos;
302 int len; 306 int len;
303 char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 307 char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62
304 308
305 309
306 // /*------------------------------------ 310 // /*------------------------------------
307 int w_len; 311 int w_len;
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
@@ -3,71 +3,61 @@
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
22class QClipboard; 22class QClipboard;
23class QCheckListItem; 23class QCheckListItem;
24class QPushButton; 24class QPushButton;
25class QListView; 25class 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
36class BenchmarkInfo : public QWidget 27class BenchmarkInfo : public QWidget
37{ 28{
38 Q_OBJECT 29 Q_OBJECT
39 30
40public: 31public:
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;
48 QCheckListItem* test_ram; 39 QCheckListItem* test_ram;
49 QCheckListItem* test_sd; 40 QCheckListItem* test_sd;
50 QCheckListItem* test_cf; 41 QCheckListItem* test_cf;
51 42
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
70private slots: 60private slots:
71 void run(); 61 void run();
72 62
73}; 63};