wxArt2D
prfltmr.h
Go to the documentation of this file.
1 /*! \file wx/genart/prfltmr.h
2  \brief profiling classes
3  \author Michael Sögtrop
4  \date Created 08/05/2004
5 
6  Copyright: 2004-2004 (c) Michael Sögtrop
7 
8  Licence: wxWidgets Licence
9 
10  RCS-ID: $Id: prfltmr.h,v 1.7 2005/08/16 16:47:52 titato Exp $
11 */
12 //
13 // Zusammenfassung der Anwendungsdetails der Klasse a2dProfilerTimer
14 //
15 // a2dProfilerTimer dient dazu die Zeit, die ein Programm in einem bestimmten Block
16 // verbringt zu messen. Der Vorteil gegnüber dem normalen Profiler liegt
17 // darin, daß das ganze Programm nicht wesentlich gebremst wird. Außerdem kann
18 // man da messen, wo man es für richtig hält, und nicht nur an Funktionsen. Die
19 // Anwendung ist denkbar einfach. Der zu profilende Block wird wie folgt
20 // geklammert:
21 //
22 // PRFL_BGN_TMR(InteressanteSchleife)
23 //
24 // for(int i=0; i<100; i++) {
25 // viel Rechnen
26 // }
27 //
28 // PRFL_END_TMR(InteressanteSchleife)
29 //
30 // a2dProfilerTimer zählt auch die Anzahl der Aufrufe von PRFL_BNG_TMR, so daß auch die
31 // Zeit pro Aufruf berechnet werden kann.
32 // Die Profileinformation wird am Programmende automatisch in die Datei Profile.txt
33 // gesichert.
34 //
35 // Wenn auch die Zahl der Durchläufe in der Schleife interessieren, kann man
36 // in der Schleife PRFL_CNT(Anzahl_Durchlaeufe) angeben.
37 //
38 // Die Argumente in den Klammern der Makros müssen gültige C-Identifier sein.
39 // Dem Identifier wird das Präfix prfl_ vorgestellt. Mit diesem Präfix muß// er in der Funktion eindeutig sein. // Der Identifier sollte nicht länger als 20 Zeichen sein // // Profiling ist nur eingeschaltet, wenn das macro PRFL_ENBL definiert ist // oder wenn die Datei PrflEnbl.h includiert wird. // // siehe auch: // prflCnt.h // prflCntTmr.h // /////////////////////////////////////////////////////////////////////////////// #if(defined(TRACE_H)) #pragma message(__FILE__) #endif /////////////////////////////////////////////////////////////////////////////// // // Schutz gegen doppelte Einbindung // /////////////////////////////////////////////////////////////////////////////// #if(!defined(PrflTmr_H)) #define PrflTmr_H /////////////////////////////////////////////////////////////////////////////// // // Test der vorausgesetzten include Dateien // /////////////////////////////////////////////////////////////////////////////// #if(!defined(Prfl_H)) #error Please include Prfl.h before including PrflTmr.h #endif //! profile timer class A2DGENERALDLLEXP a2dProfilerTimer : public a2dProfiler { public: //! constructor a2dProfilerTimer( const wxString& idIn ); //! destructor ~a2dProfilerTimer (); public: //! Help-Struct to automatically call EndBlck() when going out of scope. struct SPrflTmrAuto { //! constructor calls BgnBlck() SPrflTmrAuto( a2dProfilerTimer* prflIn ) {prfl = prflIn; prfl->BgnBlck();} //! destructor calls EndBlck() ~SPrflTmrAuto() {prfl->EndBlck();} //! timer on which this applies a2dProfilerTimer* prfl; }; public: //! is called at the start of a scope void BgnBlck(); //! is called at the end of a scope void EndBlck(); protected: wxInt64 time; unsigned long cnt; }; //***************************************************************************** //* //* Definition of Macros //* //***************************************************************************** #if(defined(PRFL_ENBL)) #define PRFL_BGN_TMR(id) static a2dProfilerTimer prfl_##id(_T(#id)); prfl_##id.BgnBlck(); #define PRFL_END_TMR(id) prfl_##id.EndBlck(); #define PRFL_AUTO_TMR(id) static a2dProfilerTimer prfl_auto1_##id(_T(#id)); a2dProfilerTimer::SPrflTmrAuto prfl_auto2_##id(&prfl_auto1_##id); #else #define PRFL_BGN_TMR(id) #define PRFL_END_TMR(id) #define PRFL_AUTO_TMR(id) #endif #endif // PrflTmr_H
40 // er in der Funktion eindeutig sein.
41 // Der Identifier sollte nicht länger als 20 Zeichen sein
42 //
43 // Profiling ist nur eingeschaltet, wenn das macro PRFL_ENBL definiert ist
44 // oder wenn die Datei PrflEnbl.h includiert wird.
45 //
46 // siehe auch:
47 // prflCnt.h
48 // prflCntTmr.h
49 //
50 ///////////////////////////////////////////////////////////////////////////////
51 
52 #if(defined(TRACE_H))
53 #pragma message(__FILE__)
54 #endif
55 
56 ///////////////////////////////////////////////////////////////////////////////
57 //
58 // Schutz gegen doppelte Einbindung
59 //
60 ///////////////////////////////////////////////////////////////////////////////
61 
62 #if(!defined(PrflTmr_H))
63 #define PrflTmr_H
64 
65 ///////////////////////////////////////////////////////////////////////////////
66 //
67 // Test der vorausgesetzten include Dateien
68 //
69 ///////////////////////////////////////////////////////////////////////////////
70 
71 #if(!defined(Prfl_H))
72 #error Please include Prfl.h before including PrflTmr.h
73 #endif
74 
75 //! profile timer
76 class A2DGENERALDLLEXP a2dProfilerTimer : public a2dProfiler
77 {
78 
79 public:
80 
81  //! constructor
82  a2dProfilerTimer( const wxString& idIn );
83 
84  //! destructor
85  ~a2dProfilerTimer ();
86 
87 public:
88 
89  //! Help-Struct to automatically call EndBlck() when going out of scope.
90  struct SPrflTmrAuto
91  {
92  //! constructor calls BgnBlck()
93  SPrflTmrAuto( a2dProfilerTimer* prflIn ) {prfl = prflIn; prfl->BgnBlck();}
94  //! destructor calls EndBlck()
95  ~SPrflTmrAuto() {prfl->EndBlck();}
96 
97  //! timer on which this applies
99  };
100 
101 public:
102 
103  //! is called at the start of a scope
104  void BgnBlck();
105 
106  //! is called at the end of a scope
107  void EndBlck();
108 
109 protected:
110 
111  wxInt64 time;
112  unsigned long cnt;
113 };
114 
115 
116 //*****************************************************************************
117 //*
118 //* Definition of Macros
119 //*
120 //*****************************************************************************
121 
122 #if(defined(PRFL_ENBL))
123 #define PRFL_BGN_TMR(id) static a2dProfilerTimer prfl_##id(_T(#id)); prfl_##id.BgnBlck();
124 #define PRFL_END_TMR(id) prfl_##id.EndBlck();
125 #define PRFL_AUTO_TMR(id) static a2dProfilerTimer prfl_auto1_##id(_T(#id)); a2dProfilerTimer::SPrflTmrAuto prfl_auto2_##id(&prfl_auto1_##id);
126 #else
127 #define PRFL_BGN_TMR(id)
128 #define PRFL_END_TMR(id)
129 #define PRFL_AUTO_TMR(id)
130 #endif
131 
132 #endif // PrflTmr_H
profile timer
Definition: prfltmr.h:76
void BgnBlck()
is called at the start of a scope
Definition: prfltmr.cpp:83
Help-Struct to automatically call EndBlck() when going out of scope.
Definition: prfltmr.h:90
~SPrflTmrAuto()
destructor calls EndBlck()
Definition: prfltmr.h:95
a2dProfilerTimer * prfl
timer on which this applies
Definition: prfltmr.h:98
SPrflTmrAuto(a2dProfilerTimer *prflIn)
constructor calls BgnBlck()
Definition: prfltmr.h:93
prfltmr.h Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation