00001 #ifndef _MY_Timer_ 00002 #define _MY_Timer_ 00003 #include <sys/time.h> 00004 #include <time.h> 00005 #include <string> 00006 00007 /*----------------- CLASS Timer -------------- 00008 ----------------------------------------*/ 00009 enum TimerType {CALENDAR_TIME,PROCESSOR_TIME}; 00010 00011 class Timer 00012 { 00013 private: 00014 clock_t t0; 00015 clock_t t1; 00016 double msecs; 00017 00018 00019 time_t tc0; 00020 TimerType m_type; 00021 protected: 00022 00023 public: 00024 Timer(TimerType type); 00025 ~Timer(){} 00026 void start(); 00027 void end(); 00028 void reset(){msecs=0.0;} 00029 std::string printTime(); 00030 }; 00031 00032 #endif