Diffstat (limited to 'noncore/settings/sysinfo/benchmarkinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 0aeb251..d6ecec5 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -1,340 +1,340 @@ | |||
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 | 46 | ||
47 | #include "benchmarkinfo.h" | 47 | #include "benchmarkinfo.h" |
48 | 48 | ||
49 | extern "C" | 49 | extern "C" |
50 | { | 50 | { |
51 | void BenchFFT( void ); | 51 | void BenchFFT( void ); |
52 | double dhry_main( int ); | 52 | double dhry_main( int ); |
53 | } | 53 | } |
54 | 54 | ||
55 | #define DHRYSTONE_RUNS 20000000 | 55 | #define DHRYSTONE_RUNS 20000000 |
56 | #define TEST_DURATION 3 | 56 | #define TEST_DURATION 3 |
57 | 57 | ||
58 | #define BUFF_SIZE 8192 | 58 | #define BUFF_SIZE 8192 |
59 | #define FILE_SIZE 1024 * 1024 // 1Mb | 59 | #define FILE_SIZE 1024 * 1024 // 1Mb |
60 | 60 | ||
61 | //=========================================================================== | 61 | //=========================================================================== |
62 | 62 | ||
63 | class BenchmarkPaintWidget : public QWidget | 63 | class BenchmarkPaintWidget : public QWidget |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
67 | { | 67 | { |
68 | resize( QApplication::desktop()->size() ); | 68 | resize( QApplication::desktop()->size() ); |
69 | show(); | 69 | show(); |
70 | p.begin( this ); | 70 | p.begin( this ); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | ~BenchmarkPaintWidget() | 73 | ~BenchmarkPaintWidget() |
74 | { | 74 | { |
75 | p.end(); | 75 | p.end(); |
76 | hide(); | 76 | hide(); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | QPainter p; | 79 | QPainter p; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | //=========================================================================== | 82 | //=========================================================================== |
83 | 83 | ||
84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
85 | : QWidget( parent, name, wFlags ) | 85 | : QWidget( parent, name, wFlags ) |
86 | { | 86 | { |
87 | 87 | ||
88 | setMinimumSize( 200, 150 ); | 88 | setMinimumSize( 200, 150 ); |
89 | 89 | ||
90 | QVBoxLayout* vb = new QVBoxLayout( this ); | 90 | QVBoxLayout* vb = new QVBoxLayout( this ); |
91 | vb->setSpacing( 4 ); | 91 | vb->setSpacing( 4 ); |
92 | vb->setMargin( 4 ); | 92 | vb->setMargin( 4 ); |
93 | 93 | ||
94 | tests = new QListView( this ); | 94 | tests = new QListView( this ); |
95 | tests->setMargin( 0 ); | 95 | tests->setMargin( 0 ); |
96 | tests->addColumn( tr( "Tests" ) ); | 96 | tests->addColumn( tr( "Tests" ) ); |
97 | tests->addColumn( tr( "Results" ) ); | 97 | tests->addColumn( tr( "Results" ) ); |
98 | tests->addColumn( tr( "Comparison" ) ); | 98 | tests->addColumn( tr( "Comparison" ) ); |
99 | tests->setShowSortIndicator( true ); | 99 | tests->setShowSortIndicator( true ); |
100 | 100 | ||
101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); | 101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); |
102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); | 102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); |
103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); | 103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); |
104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); | 104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); |
105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); | 105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); |
106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); | 106 | 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 ); | 107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); |
108 | 108 | ||
109 | test_alu->setText( 1, "n/a" ); | 109 | test_alu->setText( 1, "n/a" ); |
110 | test_fpu->setText( 1, "n/a" ); | 110 | test_fpu->setText( 1, "n/a" ); |
111 | test_txt->setText( 1, "n/a" ); | 111 | test_txt->setText( 1, "n/a" ); |
112 | test_gfx->setText( 1, "n/a" ); | 112 | test_gfx->setText( 1, "n/a" ); |
113 | test_ram->setText( 1, "n/a" ); | 113 | test_ram->setText( 1, "n/a" ); |
114 | test_sd->setText( 1, "n/a" ); | 114 | test_sd->setText( 1, "n/a" ); |
115 | test_cf->setText( 1, "n/a" ); | 115 | test_cf->setText( 1, "n/a" ); |
116 | 116 | ||
117 | test_alu->setText( 2, "n/a" ); | 117 | test_alu->setText( 2, "n/a" ); |
118 | test_fpu->setText( 2, "n/a" ); | 118 | test_fpu->setText( 2, "n/a" ); |
119 | test_txt->setText( 2, "n/a" ); | 119 | test_txt->setText( 2, "n/a" ); |
120 | test_gfx->setText( 2, "n/a" ); | 120 | test_gfx->setText( 2, "n/a" ); |
121 | test_ram->setText( 2, "n/a" ); | 121 | test_ram->setText( 2, "n/a" ); |
122 | test_sd->setText( 2, "n/a" ); | 122 | test_sd->setText( 2, "n/a" ); |
123 | test_cf->setText( 2, "n/a" ); | 123 | test_cf->setText( 2, "n/a" ); |
124 | 124 | ||
125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
127 | 127 | ||
128 | vb->addWidget( tests, 2 ); | 128 | vb->addWidget( tests, 2 ); |
129 | 129 | ||
130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
131 | if ( f.open( IO_ReadOnly ) ) | 131 | if ( f.open( IO_ReadOnly ) ) |
132 | { | 132 | { |
133 | machineCombo = new QComboBox( this ); | 133 | machineCombo = new QComboBox( this ); |
134 | 134 | ||
135 | QTextStream ts( &f ); | 135 | QTextStream ts( &f ); |
136 | while( !ts.eof() ) | 136 | while( !ts.eof() ) |
137 | { | 137 | { |
138 | QString machline = ts.readLine(); | 138 | QString machline = ts.readLine(); |
139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
140 | QString resline = ts.readLine(); | 140 | QString resline = ts.readLine(); |
141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
142 | machineCombo->insertItem( machline ); | 142 | machineCombo->insertItem( machline ); |
143 | } | 143 | } |
144 | 144 | ||
145 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 145 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
147 | hb->addWidget( machineCombo, 2 ); | 147 | hb->addWidget( machineCombo, 2 ); |
148 | connect( machineCombo, SIGNAL( activated( int ) ), this, SLOT( machineActivated( int ) ) ); | 148 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | vb->addWidget( startButton, 2 ); | 151 | vb->addWidget( startButton, 2 ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | BenchmarkInfo::~BenchmarkInfo() | 155 | BenchmarkInfo::~BenchmarkInfo() |
156 | {} | 156 | {} |
157 | 157 | ||
158 | 158 | ||
159 | void BenchmarkInfo::machineActivated( int index ) | 159 | void BenchmarkInfo::machineActivated( int index ) |
160 | { | 160 | { |
161 | QStringList* results = machines[ machineCombo->text( index ) ]; | 161 | QStringList* results = machines[ machineCombo->text( index ) ]; |
162 | if ( !results ) | 162 | if ( !results ) |
163 | { | 163 | { |
164 | qDebug( "sysinfo: no results available." ); | 164 | qDebug( "sysinfo: no results available." ); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | QStringList::Iterator it = results->begin(); | 167 | QStringList::Iterator it = results->begin(); |
168 | test_alu->setText( 2, *(it++) ); | 168 | test_alu->setText( 2, *(it++) ); |
169 | test_fpu->setText( 2, *(it++) ); | 169 | test_fpu->setText( 2, *(it++) ); |
170 | test_txt->setText( 2, *(it++) ); | 170 | test_txt->setText( 2, *(it++) ); |
171 | test_gfx->setText( 2, *(it++) ); | 171 | test_gfx->setText( 2, *(it++) ); |
172 | test_ram->setText( 2, *(it++) ); | 172 | test_ram->setText( 2, *(it++) ); |
173 | test_sd->setText( 2, *(it++) ); | 173 | test_sd->setText( 2, *(it++) ); |
174 | test_cf->setText( 2, *(it++) ); | 174 | test_cf->setText( 2, *(it++) ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void BenchmarkInfo::run() | 178 | void BenchmarkInfo::run() |
179 | { | 179 | { |
180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
181 | qApp->processEvents(); | 181 | qApp->processEvents(); |
182 | QTime t; | 182 | QTime t; |
183 | 183 | ||
184 | if ( test_alu->isOn() ) | 184 | if ( test_alu->isOn() ) |
185 | { | 185 | { |
186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
188 | test_alu->setOn( false ); | 188 | test_alu->setOn( false ); |
189 | } | 189 | } |
190 | 190 | ||
191 | if ( test_fpu->isOn() ) | 191 | if ( test_fpu->isOn() ) |
192 | { | 192 | { |
193 | t.start(); | 193 | t.start(); |
194 | BenchFFT(); | 194 | BenchFFT(); |
195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
196 | test_fpu->setOn( false ); | 196 | test_fpu->setOn( false ); |
197 | } | 197 | } |
198 | 198 | ||
199 | if ( test_txt->isOn() ) | 199 | if ( test_txt->isOn() ) |
200 | { | 200 | { |
201 | int value = textRendering( TEST_DURATION ); | 201 | int value = textRendering( TEST_DURATION ); |
202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); | 202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
203 | test_txt->setOn( false ); | 203 | test_txt->setOn( false ); |
204 | } | 204 | } |
205 | 205 | ||
206 | if ( test_gfx->isOn() ) | 206 | if ( test_gfx->isOn() ) |
207 | { | 207 | { |
208 | int value = gfxRendering( TEST_DURATION ); | 208 | int value = gfxRendering( TEST_DURATION ); |
209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests | 209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
210 | test_gfx->setOn( false ); | 210 | test_gfx->setOn( false ); |
211 | } | 211 | } |
212 | 212 | ||
213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
214 | { | 214 | { |
215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
216 | } | 216 | } |
217 | 217 | ||
218 | if ( test_cf->isOn() ) | 218 | if ( test_cf->isOn() ) |
219 | { | 219 | { |
220 | OStorageInfo storage; | 220 | OStorageInfo storage; |
221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( test_sd->isOn() ) | 224 | if ( test_sd->isOn() ) |
225 | { | 225 | { |
226 | OStorageInfo storage; | 226 | OStorageInfo storage; |
227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
228 | } | 228 | } |
229 | 229 | ||
230 | startButton->setText( tr( "&Start Tests!" ) ); | 230 | startButton->setText( tr( "&Start Tests!" ) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | int BenchmarkInfo::textRendering( int seconds ) | 234 | int BenchmarkInfo::textRendering( int seconds ) |
235 | { | 235 | { |
236 | QTime t; | 236 | QTime t; |
237 | t.start(); | 237 | t.start(); |
238 | int stop = t.elapsed() + seconds * 1000; | 238 | int stop = t.elapsed() + seconds * 1000; |
239 | 239 | ||
240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
243 | const QString text( "Opie Benchmark Test" ); | 243 | const QString text( "Opie Benchmark Test" ); |
244 | 244 | ||
245 | int w = QApplication::desktop()->width(); | 245 | int w = QApplication::desktop()->width(); |
246 | int h = QApplication::desktop()->height(); | 246 | int h = QApplication::desktop()->height(); |
247 | 247 | ||
248 | srand( time( NULL ) ); | 248 | srand( time( NULL ) ); |
249 | 249 | ||
250 | BenchmarkPaintWidget bpw; | 250 | BenchmarkPaintWidget bpw; |
251 | 251 | ||
252 | int loops = 0; | 252 | int loops = 0; |
253 | 253 | ||
254 | while ( t.elapsed() < stop ) | 254 | while ( t.elapsed() < stop ) |
255 | { | 255 | { |
256 | int k = rand() % 9; | 256 | int k = rand() % 9; |
257 | int s = rand() % 100; | 257 | int s = rand() % 100; |
258 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 258 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
259 | bpw.p.setFont( QFont( "Vera", s ) ); | 259 | bpw.p.setFont( QFont( "Vera", s ) ); |
260 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 260 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
261 | ++loops; | 261 | ++loops; |
262 | } | 262 | } |
263 | 263 | ||
264 | return loops * text.length(); | 264 | return loops * text.length(); |
265 | } | 265 | } |
266 | 266 | ||
267 | int BenchmarkInfo::gfxRendering( int seconds ) | 267 | int BenchmarkInfo::gfxRendering( int seconds ) |
268 | { | 268 | { |
269 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 269 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
270 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 270 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
271 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 271 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
272 | 272 | ||
273 | int w = QApplication::desktop()->width(); | 273 | int w = QApplication::desktop()->width(); |
274 | int h = QApplication::desktop()->height(); | 274 | int h = QApplication::desktop()->height(); |
275 | 275 | ||
276 | srand( time( NULL ) ); | 276 | srand( time( NULL ) ); |
277 | 277 | ||
278 | BenchmarkPaintWidget bpw; | 278 | BenchmarkPaintWidget bpw; |
279 | 279 | ||
280 | QTime t; | 280 | QTime t; |
281 | t.start(); | 281 | t.start(); |
282 | int stop = t.elapsed() + seconds*1000; | 282 | int stop = t.elapsed() + seconds*1000; |
283 | int loops = 0; | 283 | int loops = 0; |
284 | 284 | ||
285 | while ( t.elapsed() < stop ) | 285 | while ( t.elapsed() < stop ) |
286 | { | 286 | { |
287 | int k = rand() % 9; | 287 | int k = rand() % 9; |
288 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 288 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
289 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 289 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
290 | ++loops; | 290 | ++loops; |
291 | } | 291 | } |
292 | 292 | ||
293 | t.restart(); | 293 | t.restart(); |
294 | stop = t.elapsed() + seconds*1000; | 294 | stop = t.elapsed() + seconds*1000; |
295 | 295 | ||
296 | while ( t.elapsed() < stop ) | 296 | while ( t.elapsed() < stop ) |
297 | { | 297 | { |
298 | int k = rand() % 9; | 298 | int k = rand() % 9; |
299 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 299 | 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 ); | 300 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
301 | ++loops; | 301 | ++loops; |
302 | } | 302 | } |
303 | 303 | ||
304 | QBrush br1; | 304 | QBrush br1; |
305 | br1.setStyle( SolidPattern ); | 305 | br1.setStyle( SolidPattern ); |
306 | t.restart(); | 306 | t.restart(); |
307 | stop = t.elapsed() + seconds*1000; | 307 | stop = t.elapsed() + seconds*1000; |
308 | 308 | ||
309 | while ( t.elapsed() < stop ) | 309 | while ( t.elapsed() < stop ) |
310 | { | 310 | { |
311 | int k = rand() % 9; | 311 | int k = rand() % 9; |
312 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 312 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
313 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 313 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
314 | ++loops; | 314 | ++loops; |
315 | } | 315 | } |
316 | 316 | ||
317 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 317 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
318 | t.restart(); | 318 | t.restart(); |
319 | stop = t.elapsed() + seconds*1000; | 319 | stop = t.elapsed() + seconds*1000; |
320 | 320 | ||
321 | while ( t.elapsed() < stop ) | 321 | while ( t.elapsed() < stop ) |
322 | { | 322 | { |
323 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 323 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
324 | ++loops; | 324 | ++loops; |
325 | } | 325 | } |
326 | 326 | ||
327 | return loops; | 327 | return loops; |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) | 331 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) |
332 | { | 332 | { |
333 | QTime time; | 333 | QTime time; |
334 | time.start(); | 334 | time.start(); |
335 | if ( writeFile( fname ) && | 335 | if ( writeFile( fname ) && |
336 | readFile( fname ) ) | 336 | readFile( fname ) ) |
337 | { | 337 | { |
338 | QFile::remove( fname ); | 338 | QFile::remove( fname ); |
339 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); | 339 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); |
340 | item->setOn( false ); | 340 | item->setOn( false ); |