00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SG_TRC_TIMER_H
00024 #define _SG_TRC_TIMER_H
00025
00026 #ifdef __cplusplus
00027
00028 #include <SugoiTracer\config.h>
00029 #include <SugoiTools\xml.h>
00030
00031
00032
00033 #ifdef _WIN32
00034 #include <winsock.h>
00035 #else
00036 #include <sys/h>
00037 #endif
00038
00039 #include <Time.h>
00040 #include <sys/timeb.h>
00041
00042 namespace SG_TRC{
00043
00050 class _SG_TRC_DLL_EXPORT CL_Virtual_Record :
00051 public CL_XML_OBJ
00052 {
00053 public :
00054 CL_Virtual_Record(void)
00055 :CL_XML_OBJ("vrecord")
00056 {Clear();};
00057
00058 CL_Virtual_Record(const CL_Virtual_Record &_Rec2)
00059 :CL_XML_OBJ("vrecord")
00060 {Clear();};
00061
00062 CL_Virtual_Record(const long T)
00063 :CL_XML_OBJ("vrecord")
00064 {Clear();};
00065
00066 virtual ~CL_Virtual_Record(void){Clear();};
00067
00068 virtual void Clear(){};
00069 virtual void SetToMax(){};
00070 virtual void SetToMin(){};
00071
00072
00073 _SG_TRC_INLINE virtual CL_Virtual_Record& operator =( const long T){return *this;};
00074 _SG_TRC_INLINE virtual CL_Virtual_Record& operator =( const CL_Virtual_Record &_Rec2){return *this;};
00075
00076 _SG_TRC_INLINE virtual bool operator !=( const CL_Virtual_Record &_Rec2){return false;};
00077
00078 _SG_TRC_INLINE virtual bool operator ==( const CL_Virtual_Record &_Rec2){return false;};
00079
00080 _SG_TRC_INLINE virtual bool operator < ( const CL_Virtual_Record &_Rec2){return false;};
00081 _SG_TRC_INLINE virtual bool operator > ( const CL_Virtual_Record &_Rec2){return false;};
00082
00083 _SG_TRC_INLINE virtual CL_Virtual_Record& operator +=( const CL_Virtual_Record &_Rec2){return *this;};
00084 _SG_TRC_INLINE virtual CL_Virtual_Record& operator -=( const CL_Virtual_Record &_Rec2){return *this;};
00085 _SG_TRC_INLINE virtual CL_Virtual_Record& operator /=( const long T){return *this;};
00086 _SG_TRC_INLINE virtual CL_Virtual_Record& operator *=( const long T){return *this;};
00087
00088 _SG_TRC_INLINE virtual CL_Virtual_Record operator +( const CL_Virtual_Record &_Rec2){return *this;};
00089 _SG_TRC_INLINE virtual CL_Virtual_Record operator -( const CL_Virtual_Record &_Rec2){return *this;};
00090 _SG_TRC_INLINE virtual CL_Virtual_Record operator /( const long T){return *this;};
00091 _SG_TRC_INLINE virtual CL_Virtual_Record operator *( const long T){return *this;};
00092
00093
00094 _SG_TRC_INLINE virtual void Run(void){};
00095 _SG_TRC_INLINE virtual long GetValue(void){return 0;};
00096 _SG_TRC_INLINE virtual void SetValue(const long L){};
00097 _SG_TRC_INLINE virtual std::string GetStr(bool _Approxmimate=true){return "";};
00098 _SG_TRC_INLINE virtual void Print(){};
00099
00100 #if _SG_TLS_XML
00101 public:
00102 virtual TiXmlElement* XMLLoad(TiXmlElement* _XML_ROOT, std::string _Name =""){return NULL;};
00103 virtual TiXmlElement* XMLSave(TiXmlElement* _XML_ROOT, std::string _Name=""){return NULL;};
00104 #endif
00105
00106 };
00107
00108
00109
00110 typedef struct timeval ST_Timeval;
00126 class _SG_TRC_DLL_EXPORT CL_TimerVal : public CL_Virtual_Record
00127 {
00128 public :
00129
00130 long tv_sec;
00131 long tv_usec;
00132
00133
00134 CL_TimerVal(void);
00135 CL_TimerVal(const CL_TimerVal &Time2);
00136 CL_TimerVal(const CL_Virtual_Record &_Rec2);
00137 CL_TimerVal(const ST_Timeval &_Timeval);
00138 CL_TimerVal(const long T);
00139 ~CL_TimerVal(void){};
00140 void Clear();
00141 void SetToMax();
00142 void SetToMin();
00143
00144
00145 _SG_TRC_INLINE CL_TimerVal& operator =( const long T);
00146 _SG_TRC_INLINE CL_TimerVal& operator =( const CL_TimerVal &Time2);
00147
00148 _SG_TRC_INLINE CL_TimerVal& operator =( const ST_Timeval &_Timeval);
00149 _SG_TRC_INLINE bool operator !=( const CL_TimerVal &Time2);
00150
00151 _SG_TRC_INLINE bool operator ==( const CL_TimerVal &Time2);
00152
00153 _SG_TRC_INLINE bool operator < ( const CL_TimerVal &Time2);
00154 _SG_TRC_INLINE bool operator > ( const CL_TimerVal &Time2);
00155
00156 _SG_TRC_INLINE CL_TimerVal& operator +=( const CL_TimerVal &Time2);
00157 _SG_TRC_INLINE CL_TimerVal& operator -=( const CL_TimerVal &Time2);
00158 _SG_TRC_INLINE CL_TimerVal& operator /=( const long T);
00159 _SG_TRC_INLINE CL_TimerVal& operator *=( const long T);
00160
00161 _SG_TRC_INLINE CL_TimerVal operator +( const CL_TimerVal &Time2)const;
00162 _SG_TRC_INLINE CL_TimerVal operator -( const CL_TimerVal &Time2)const;
00163 _SG_TRC_INLINE CL_TimerVal operator /( const long T)const;
00164 _SG_TRC_INLINE CL_TimerVal operator *( const long T)const;
00165
00166
00167
00168 _SG_TRC_INLINE void AddTimeUs(const unsigned int _time);
00169 _SG_TRC_INLINE void AddTimeMs(const unsigned int _time);
00170 _SG_TRC_INLINE long GetValue(void);
00171 _SG_TRC_INLINE std::string GetStr(bool _Approxmimate=true)const;
00172 _SG_TRC_INLINE void Print();
00173 _SG_TRC_INLINE void Run(CL_TimerVal * StopTime=NULL);
00174
00175 bool succes;
00176 int returnValue;
00177
00178
00179 #if _SG_TLS_XML
00180 public:
00181 TiXmlElement* XMLLoad(TiXmlElement* _XML_ROOT, std::string _Name ="");
00182 TiXmlElement* XMLSave(TiXmlElement* _XML_ROOT, std::string _Name="");
00183 #endif
00184 };
00185
00186 extern "C"
00187 {
00188 #endif
00189
00190 _SG_TLS_EXPORT int Ygettimeofday(struct timeval * tp);
00191 _SG_TLS_EXPORT void cleartimeval(struct timeval * t1);
00192
00193 };
00194 #ifdef __cplusplus
00195 }
00196 #endif
00197
00198 #endif//_SG_TRC_TIMER_H