00001 #ifndef TIMER_H_ 00002 #define TIMER_H_ 00003 #include <sys/time.h> 00004 #include <iostream> 00005 class MricpTimer 00006 { 00007 private: 00008 struct timeval start_time,end_time; 00009 double time_diff; 00010 public: 00011 MricpTimer(); 00012 double TimeElapsed(); // time elapsed in usec since last call 00013 void Reset(); // resets timer 00014 virtual ~MricpTimer(); 00015 /* Synchronize the loop within a period 00016 * To use this u will have to initialize the timer 00017 * reset the timer at the beginning of the loop 00018 * and call the Synch function at the end of the loop 00019 */ 00020 void Synch(double period); // period should be in msec 00021 }; 00022 00023 #endif /*TIMER_H_*/