• Main Page
  • Classes
  • Files
  • File List

Common/Timer.h

00001 /*
00002  * Timer.h
00003  *
00004  *  Created on: 24-11-2010
00005  *      Author: marcin
00006  */
00007 
00008 #ifndef TIMER_H_
00009 #define TIMER_H_
00010 
00011 #ifdef WINDOWS   // Windows
00012 #include <windows.h>
00013 #else          // Unix
00014 #include <sys/time.h>
00015 #endif
00016 
00017 
00018 class Timer
00019 {
00020 private:
00021     double startTimeInMicroSec;                 // starting time in micro-second
00022     double endTimeInMicroSec;                   // ending time in micro-second
00023     bool   ticking;                             // stop flag
00024 #ifdef WINDOWS
00025     LARGE_INTEGER frequency;                    // ticks per second
00026     LARGE_INTEGER startCount;                   //
00027     LARGE_INTEGER endCount;                     //
00028 #else
00029     timeval startCount;                         //
00030     timeval endCount;                           //
00031 #endif
00032 
00033 
00034 
00035 public:
00036     Timer();
00037     ~Timer();
00038 
00039     void   start();                             // start timer
00040     void stop();                              // stop the timer, and return time in mirco-second
00041     double getElapsedTimeInMilliSec();          // get elapsed time in milli-second
00042     double getElapsedTimeInMicroSec();          // get elapsed time in micro-second
00043     double getTimerSnapshot();
00044 };
00045 
00046 #endif /* TIMER_H_ */

Generated on Sun Dec 5 2010 19:03:32 for Snook3d by  doxygen 1.7.2