2 #include "../Common/Common.h"
4 #include "SimpleTimer.h"
12 // Track memory leaks on Windows to the line that new'd the memory
15 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
18 static char THIS_FILE
[] = __FILE__
;
22 CSimpleTimer::CSimpleTimer()
25 struct timeb sTimeBuffer
;
27 struct timeval sTimeBuffer
;
28 struct timezone sTimezoneBuffer
;
33 m_iStartMs
= sTimeBuffer
.millitm
;
34 m_iStartSecond
= sTimeBuffer
.time
;
36 gettimeofday(&sTimeBuffer
, &sTimezoneBuffer
);
37 m_iStartMs
= (int)sTimeBuffer
.tv_usec
/ 1000;
38 m_iStartSecond
= (int)sTimeBuffer
.tv_sec
;
43 CSimpleTimer::~CSimpleTimer()
47 double CSimpleTimer::GetElapsed()
50 struct timeb sTimeBuffer
;
52 struct timeval sTimeBuffer
;
53 struct timezone sTimezoneBuffer
;
58 int iEndMs
= sTimeBuffer
.millitm
;
59 int iEndSecond
= sTimeBuffer
.time
;
61 gettimeofday(&sTimeBuffer
, &sTimezoneBuffer
);
62 int iEndMs
= (int)sTimeBuffer
.tv_usec
/ 1000;
63 int iEndSecond
= (int)sTimeBuffer
.tv_sec
;
67 return ((double) iEndMs
/ 1000.0 + (double) iEndSecond
) -
68 ((double) m_iStartMs
/ 1000.0 + (double) m_iStartSecond
);