VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ssTimer.h
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 #ifndef SS_TIMER
10 #define SS_TIMER
11 
12 #ifdef WIN32
13 #include <Windows.h>
14 #else
15 #include <sys/time.h>
16 #endif
17 
18 #include "ssdllexport.h"
19 
27 {
28 public:
29 
35  {
36 
37 #ifdef WIN32
38  LARGE_INTEGER frequency;
39  QueryPerformanceFrequency( &frequency );
40  m_ticksPerSecond = frequency.QuadPart;
41 #else
42 #endif
43  // Prepare the timer to start counting seconds
44  reset();
45 
46  }
47 
48 
53  void reset()
54  {
55 #ifdef WIN32
56  LARGE_INTEGER currentTime;
57  QueryPerformanceCounter( &currentTime );
58  m_startTime = currentTime.QuadPart;
59 #else
60  struct timezone tz;
61  gettimeofday( &m_startTime, &tz);
62 #endif
63  }
64 
65 
70  double getTime()
71  {
72  double rtn = 0.0;
73 
74 #ifdef WIN32
75  LARGE_INTEGER currentTime;
76  QueryPerformanceCounter( &currentTime );
77 
78  rtn = double( currentTime.QuadPart - m_startTime ) /
79  double( m_ticksPerSecond );
80 #else
81  struct timeval currentTime;
82  struct timezone tz;
83  gettimeofday( &currentTime, &tz );
84 
85  double seconds = currentTime.tv_sec - m_startTime.tv_sec;
86  double useconds = currentTime.tv_usec - m_startTime.tv_usec;
87 
88  rtn = seconds + ( useconds / 1000000.0 );
89 #endif
90 
91  return rtn;
92  }
93 
94 private:
95 
96 #ifdef WIN32
97  LONGLONG m_ticksPerSecond;
98  LONGLONG m_startTime;
99 #else
100  struct timeval m_startTime;
101 #endif
102 
103 };
104 
105 #endif // ifdef SS_TIMER


Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)