summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/benchmarkinfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/benchmarkinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 793fcb1..060185a 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -49,193 +49,193 @@ using namespace Opie::Ui;
49#include <time.h> 49#include <time.h>
50#include <stdio.h> 50#include <stdio.h>
51#include <stdlib.h> 51#include <stdlib.h>
52#include <math.h> 52#include <math.h>
53#if defined (__GNUC__) && (__GNUC__ < 3) 53#if defined (__GNUC__) && (__GNUC__ < 3)
54#define round qRound 54#define round qRound
55#endif 55#endif
56 56
57extern "C" 57extern "C"
58{ 58{
59 void BenchFFT( void ); 59 void BenchFFT( void );
60 double dhry_main( int ); 60 double dhry_main( int );
61} 61}
62 62
63#define DHRYSTONE_RUNS 20000000 63#define DHRYSTONE_RUNS 20000000
64#define TEST_DURATION 3 64#define TEST_DURATION 3
65 65
66//=========================================================================== 66//===========================================================================
67 67
68class BenchmarkPaintWidget : public QWidget 68class BenchmarkPaintWidget : public QWidget
69{ 69{
70 public: 70 public:
71 BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) 71 BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever )
72 { 72 {
73 resize( QApplication::desktop()->size() ); 73 resize( QApplication::desktop()->size() );
74 show(); 74 show();
75 p.begin( this ); 75 p.begin( this );
76 }; 76 };
77 77
78 ~BenchmarkPaintWidget() 78 ~BenchmarkPaintWidget()
79 { 79 {
80 p.end(); 80 p.end();
81 hide(); 81 hide();
82 }; 82 };
83 83
84 QPainter p; 84 QPainter p;
85}; 85};
86 86
87//=========================================================================== 87//===========================================================================
88 88
89BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) 89BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
90 : QWidget( parent, name, wFlags ) 90 : QWidget( parent, name, wFlags )
91{ 91{
92 92
93 setMinimumSize( 200, 150 ); 93 setMinimumSize( 200, 150 );
94 94
95 QVBoxLayout* vb = new QVBoxLayout( this ); 95 QVBoxLayout* vb = new QVBoxLayout( this );
96 vb->setSpacing( 4 ); 96 vb->setSpacing( 4 );
97 vb->setMargin( 4 ); 97 vb->setMargin( 4 );
98 98
99 tests = new OListView( this ); 99 tests = new OListView( this );
100 QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " 100 QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests "
101 "have been performed, and comparison values for one selected device. " 101 "have been performed, and comparison values for one selected device. "
102 "Use the checkboxes to define which tests you want to perform." ) ); 102 "Use the checkboxes to define which tests you want to perform." ) );
103 tests->setMargin( 0 ); 103 tests->setMargin( 0 );
104 tests->addColumn( tr( "Tests" ) ); 104 tests->addColumn( tr( "Tests" ) );
105 tests->addColumn( tr( "Results" ) ); 105 tests->addColumn( tr( "Results" ) );
106 tests->addColumn( tr( "Comparison" ) ); 106 tests->addColumn( tr( "Comparison" ) );
107 tests->setShowSortIndicator( true ); 107 tests->setShowSortIndicator( true );
108 108
109 test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); 109 test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox );
110 test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); 110 test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox );
111 test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); 111 test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox );
112 test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); 112 test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox );
113 test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); 113 test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox );
114#ifndef QT_QWS_RAMSES 114#ifndef QT_QWS_RAMSES
115 test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); 115 test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox );
116 test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); 116 test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox );
117#endif 117#endif
118 test_alu->setText( 1, "n/a" ); 118 test_alu->setText( 1, "n/a" );
119 test_fpu->setText( 1, "n/a" ); 119 test_fpu->setText( 1, "n/a" );
120 test_txt->setText( 1, "n/a" ); 120 test_txt->setText( 1, "n/a" );
121 test_gfx->setText( 1, "n/a" ); 121 test_gfx->setText( 1, "n/a" );
122 test_ram->setText( 1, "n/a" ); 122 test_ram->setText( 1, "n/a" );
123#ifndef QT_QWS_RAMSES 123#ifndef QT_QWS_RAMSES
124 test_sd->setText( 1, "n/a" ); 124 test_sd->setText( 1, "n/a" );
125 test_cf->setText( 1, "n/a" ); 125 test_cf->setText( 1, "n/a" );
126#endif 126#endif
127 test_alu->setText( 2, "n/a" ); 127 test_alu->setText( 2, "n/a" );
128 test_fpu->setText( 2, "n/a" ); 128 test_fpu->setText( 2, "n/a" );
129 test_txt->setText( 2, "n/a" ); 129 test_txt->setText( 2, "n/a" );
130 test_gfx->setText( 2, "n/a" ); 130 test_gfx->setText( 2, "n/a" );
131 test_ram->setText( 2, "n/a" ); 131 test_ram->setText( 2, "n/a" );
132#ifndef QT_QWS_RAMSES 132#ifndef QT_QWS_RAMSES
133 test_sd->setText( 2, "n/a" ); 133 test_sd->setText( 2, "n/a" );
134 test_cf->setText( 2, "n/a" ); 134 test_cf->setText( 2, "n/a" );
135#endif 135#endif
136 136
137 startButton = new QPushButton( tr( "&Start Tests!" ), this ); 137 startButton = new QPushButton( tr( "&Start Tests!" ), this );
138 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); 138 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) );
139 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); 139 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
140 vb->addWidget( tests, 2 ); 140 vb->addWidget( tests, 2 );
141 141
142 QHBoxLayout* hb = new QHBoxLayout( vb ); 142 QHBoxLayout* hb = new QHBoxLayout( vb );
143 hb->addWidget( startButton, 2 ); 143 hb->addWidget( startButton, 2 );
144 144
145 QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); 145 QFile f( QPEApplication::qpeDir() + "share/sysinfo/results" );
146 if ( f.open( IO_ReadOnly ) ) 146 if ( f.open( IO_ReadOnly ) )
147 { 147 {
148 machineCombo = new QComboBox( this ); 148 machineCombo = new QComboBox( this );
149 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); 149 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) );
150 150
151 QTextStream ts( &f ); 151 QTextStream ts( &f );
152 while( !ts.eof() ) 152 while( !ts.eof() )
153 { 153 {
154 QString machline = ts.readLine(); 154 QString machline = ts.readLine();
155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; 155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl;
156 QString resline = ts.readLine(); 156 QString resline = ts.readLine();
157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); 157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
158 machineCombo->insertItem( machline ); 158 machineCombo->insertItem( machline );
159 } 159 }
160 160
161 hb->addWidget( new QLabel( tr( "Compare:" ), this ) ); 161 hb->addWidget( new QLabel( tr( "Compare:" ), this ) );
162 hb->addWidget( machineCombo, 2 ); 162 hb->addWidget( machineCombo, 2 );
163 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); 163 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) );
164 } 164 }
165} 165}
166 166
167 167
168BenchmarkInfo::~BenchmarkInfo() 168BenchmarkInfo::~BenchmarkInfo()
169{} 169{}
170 170
171 171
172void BenchmarkInfo::machineActivated( int index ) 172void BenchmarkInfo::machineActivated( int index )
173{ 173{
174 QStringList* results = machines[ machineCombo->text( index ) ]; 174 QStringList* results = machines[ machineCombo->text( index ) ];
175 if ( !results ) 175 if ( !results )
176 { 176 {
177 odebug << "sysinfo: no results available." << oendl; 177 odebug << "sysinfo: no results available." << oendl;
178 return; 178 return;
179 } 179 }
180 QStringList::Iterator it = results->begin(); 180 QStringList::Iterator it = results->begin();
181 test_alu->setText( 2, *(it++) ); 181 test_alu->setText( 2, *(it++) );
182 test_fpu->setText( 2, *(it++) ); 182 test_fpu->setText( 2, *(it++) );
183 test_txt->setText( 2, *(it++) ); 183 test_txt->setText( 2, *(it++) );
184 test_gfx->setText( 2, *(it++) ); 184 test_gfx->setText( 2, *(it++) );
185 test_ram->setText( 2, *(it++) ); 185 test_ram->setText( 2, *(it++) );
186#ifndef QT_QWS_RAMSES 186#ifndef QT_QWS_RAMSES
187 test_sd->setText( 2, *(it++) ); 187 test_sd->setText( 2, *(it++) );
188 test_cf->setText( 2, *(it++) ); 188 test_cf->setText( 2, *(it++) );
189#endif 189#endif
190} 190}
191 191
192 192
193void BenchmarkInfo::run() 193void BenchmarkInfo::run()
194{ 194{
195 startButton->setText( "> Don't touch! <" ); 195 startButton->setText( "> Don't touch! <" );
196 qApp->processEvents(); 196 qApp->processEvents();
197 QTime t; 197 QTime t;
198 198
199 if ( test_alu->isOn() ) 199 if ( test_alu->isOn() )
200 { 200 {
201 int d = round( dhry_main( DHRYSTONE_RUNS ) ); 201 int d = round( dhry_main( DHRYSTONE_RUNS ) );
202 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); 202 test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) );
203 test_alu->setOn( false ); 203 test_alu->setOn( false );
204 } 204 }
205 205
206 if ( test_fpu->isOn() ) 206 if ( test_fpu->isOn() )
207 { 207 {
208 t.start(); 208 t.start();
209 BenchFFT(); 209 BenchFFT();
210 test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );; 210 test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );;
211 test_fpu->setOn( false ); 211 test_fpu->setOn( false );
212 } 212 }
213 213
214 if ( test_txt->isOn() ) 214 if ( test_txt->isOn() )
215 { 215 {
216 int value = textRendering( TEST_DURATION ); 216 int value = textRendering( TEST_DURATION );
217 test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); 217 test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) );
218 test_txt->setOn( false ); 218 test_txt->setOn( false );
219 } 219 }
220 220
221 if ( test_gfx->isOn() ) 221 if ( test_gfx->isOn() )
222 { 222 {
223 int value = gfxRendering( TEST_DURATION ); 223 int value = gfxRendering( TEST_DURATION );
224 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests 224 test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests
225 test_gfx->setOn( false ); 225 test_gfx->setOn( false );
226 } 226 }
227 227
228 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA 228 if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA
229 { 229 {
230 performFileTest( "/tmp/benchmarkFile.dat", test_ram ); 230 performFileTest( "/tmp/benchmarkFile.dat", test_ram );
231 } 231 }
232 232
233#ifndef QT_QWS_RAMSES 233#ifndef QT_QWS_RAMSES
234 if ( test_cf->isOn() ) 234 if ( test_cf->isOn() )
235 { 235 {
236 OStorageInfo storage; 236 OStorageInfo storage;
237 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); 237 performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
238 } 238 }
239 239
240 if ( test_sd->isOn() ) 240 if ( test_sd->isOn() )
241 { 241 {