uLib-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Timer.h
Go to the documentation of this file.
1 #ifndef TIMER_H
2 #define TIMER_H
3 
4 #include <sys/time.h>
5 
6 
8 // Timer /////////////////////////////////////////////////////////////////////
10 
11 class Timer
12 {
13 public:
14  void Start() { gettimeofday(&m_start, NULL); }
15 
16  double StopWatch() {
17  gettimeofday(&m_end, NULL);
18  double timeSec = m_end.tv_sec - m_start.tv_sec +
19  (m_end.tv_usec - m_start.tv_usec)*1E-6;
20  return timeSec;
21  }
22 
23 private:
24  struct timeval m_start, m_end;
25 };
26 
27 
28 #endif // TIMER_H
Definition: Timer.h:11
double StopWatch()
Definition: Timer.h:16
void Start()
Definition: Timer.h:14