#include <speedtst.h>
Inheritance diagram for OpTimeDraw:
Public Member Functions | |
OpTimeDraw () | |
Constructor for OpTimeDraw operation. It is not undoable. | |
void | Do (OpDescriptor *) |
Forces a redraw of the current document and displays the time taken to do. | |
Static Public Member Functions | |
static BOOL | Init () |
Declares op descriptors for time testing. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
This item is always available, so long as a document is visible. |
Definition at line 121 of file speedtst.h.
|
Constructor for OpTimeDraw operation. It is not undoable.
Definition at line 327 of file speedtst.cpp.
|
|
Forces a redraw of the current document and displays the time taken to do.
Reimplemented from Operation. Definition at line 224 of file speedtst.cpp. 00225 { 00226 // SpeedTest_Count++; 00227 00228 DocView *pDocView = DocView::GetSelected(); 00229 if (pDocView == NULL) 00230 return; 00231 00232 wxYield(); // let through some wxPaint events 00233 00234 CamProfiler Profiler; 00235 // clock() measures system time so excludes (e.g.) X-Windows blit time 00236 // so this is rather a peculiar test 00237 clock_t Timer = clock(); // start clock 00238 00239 pDocView->ForceRedraw(); // posts the paint message 00240 00241 wxWindow* pWnd = DocView::GetCurrentRenderWindow(); 00242 if (pWnd) 00243 pWnd->Update(); // do the paint 00244 00245 // now we wait until all rendering has finished 00246 while ( Camelot.ServiceRendering() ) 00247 { 00248 } 00249 00250 Timer = clock() - Timer; // stop clock 00251 00252 double Results[CAMPROFILE_NONE]; 00253 double total = Profiler.Read(Results); 00254 00255 // as this is for our use only, it is permitted to hard-code English strings 00256 00257 // this lovely line translates the clock_t value into a useful value without using 00258 // floats 00259 String_256 Buf; // "Redraw took %d.%03d secs" 00260 00261 Buf.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK), (INT32)(Timer / CLOCKS_PER_SEC), 00262 (INT32)((Timer % CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC) ); 00263 #if 1 00264 00265 // All this because MakeMsg doesn't do floating point 00266 #define PFORM(x) ((INT32)((x<0)?ceil(x):floor(x))) , ((INT32)(floor(0.5+( ( (x<0)?(ceil(x)-x):(x - floor(x)) ) * 1000 )))) 00267 00268 double error=Results[CAMPROFILE_OTHER ]+ 00269 Results[CAMPROFILE_GDRAW ]+ 00270 Results[CAMPROFILE_SHADOW]+ 00271 Results[CAMPROFILE_BEVEL ]+ 00272 Results[CAMPROFILE_BLIT ]-total; 00273 00274 String_256 Buf2; 00275 00276 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("TOTAL"), PFORM(total)); 00277 Buf += _T(", "); 00278 Buf += Buf2; 00279 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("GDRAW"), PFORM(Results[CAMPROFILE_GDRAW])); 00280 Buf += _T(", "); 00281 Buf += Buf2; 00282 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("SHADOW"), PFORM(Results[CAMPROFILE_SHADOW])); 00283 Buf += _T(", "); 00284 Buf += Buf2; 00285 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("BEVEL"), PFORM(Results[CAMPROFILE_BEVEL])); 00286 Buf += _T(", "); 00287 Buf += Buf2; 00288 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("BLIT"), PFORM(Results[CAMPROFILE_BLIT])); 00289 Buf += _T(", "); 00290 Buf += Buf2; 00291 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("OTHER"), PFORM(Results[CAMPROFILE_OTHER])); 00292 Buf += _T(", "); 00293 Buf += Buf2; 00294 00295 // Only report error if it is significant. With current code, it shouldn't actually exist at all bar 00296 // floating point to INT32 rounding error. 00297 if (fabs(error) > 0.5/1000.0) 00298 { 00299 Buf2.MakeMsg(_R(IDS_SPEEDTST_REDRAW_TOOK2), _T("ERROR"), PFORM(error)); 00300 Buf += _T(", "); 00301 Buf += Buf2; 00302 } 00303 00304 #endif 00305 Convert::ReplaceDecimalPoint(&Buf); // Just to keep Neville happy... :- 00306 00307 00308 // URGH! This should use the proper Camelot dialog box system but we don't have it available right now 00309 ::wxMessageBox( (TCHAR *)Buf ); 00310 00311 End(); // cleanup memory 00312 }
|
|
This item is always available, so long as a document is visible.
Definition at line 346 of file speedtst.cpp. 00347 { 00348 OpState OpSt; 00349 00350 return OpSt; 00351 }
|
|
Declares op descriptors for time testing.
Reimplemented from SimpleCCObject. Definition at line 162 of file speedtst.cpp. 00163 { 00164 BOOL bOK = TRUE; 00165 if (bOK) bOK = RegisterOpDescriptor( 00166 0, 00167 _R(IDS_TIMEDRAW), 00168 CC_RUNTIME_CLASS(OpTimeDraw), 00169 OPTOKEN_TIMEDRAW, 00170 GetState, 00171 _R(IDS_TIMEDRAW), 00172 _R(IDBBL_TIMEDRAW) 00173 ); 00174 00175 if (bOK) bOK = RegisterOpDescriptor( 00176 0, 00177 _R(IDS_CLEARCACHE), 00178 CC_RUNTIME_CLASS(OpClearCache), 00179 OPTOKEN_CLEARCACHE, 00180 GetState, 00181 _R(IDS_CLEARCACHE), 00182 _R(IDBBL_CLEARCACHE) 00183 ); 00184 00185 if (bOK) bOK = RegisterOpDescriptor( 00186 0, 00187 _R(IDS_THROTTLECACHE), 00188 CC_RUNTIME_CLASS(OpThrottleCache), 00189 OPTOKEN_THROTTLECACHE, 00190 GetState, 00191 _R(IDS_THROTTLECACHE), 00192 _R(IDBBL_THROTTLECACHE) 00193 ); 00194 00195 return bOK; 00196 }
|