00001 // -*- C++ -*- 00020 #ifndef COIL_TIMEMEASURE_H 00021 #define COIL_TIMEMEASURE_H 00022 00023 #include <vector> 00024 #include <coil/TimeValue.h> 00025 00026 namespace coil 00027 { 00028 00049 class TimeMeasure 00050 { 00051 public: 00063 struct Statistics 00064 { 00065 double max_interval; 00066 double min_interval; 00067 double mean_interval; 00068 double std_deviation; 00069 }; 00070 00086 TimeMeasure(int buflen = 100); 00087 00103 void tick(); 00104 00120 void tack(); 00121 00141 coil::TimeValue& interval(); 00142 00158 void reset(); 00159 00179 unsigned long int count() const; 00180 00210 bool getStatistics(double &max_interval, 00211 double &min_interval, 00212 double &mean_interval, 00213 double &stddev); 00214 00234 Statistics getStatistics(); 00235 00236 private: 00237 std::vector<coil::TimeValue> m_record; 00238 coil::TimeValue m_begin; 00239 coil::TimeValue m_interval; 00240 00241 unsigned long int m_count; 00242 const unsigned long int m_countMax; 00243 unsigned long long int m_cpuClock; 00244 00245 bool m_recurred; 00246 }; 00247 }; // namespace coil 00248 #endif // COIL_TIMEMEASURE_H