SkelGIS
3.0
|
00001 /*! \file chronometer.hpp 00002 * \brief Tool to calculate execution times. Not used by the user. 00003 */ 00004 #ifndef CHRONOMETER_HPP 00005 #define CHRONOMETER_HPP 00006 00007 #include <sys/time.h> 00008 #include <iostream> 00009 00010 //------------------------------------------------------------------------------- 00011 class Chronometer 00012 //------------------------------------------------------------------------------- 00013 { 00014 private: 00015 00016 timeval begin, end; 00017 00018 public: 00019 00020 //------------------------------------------------------------------------------- 00021 Chronometer(){} 00022 //------------------------------------------------------------------------------- 00023 00024 //------------------------------------------------------------------------------- 00025 inline void start() 00026 //------------------------------------------------------------------------------- 00027 { 00028 gettimeofday(&begin, NULL); 00029 } 00030 //------------------------------------------------------------------------------- 00031 00032 //------------------------------------------------------------------------------- 00033 inline void stop() 00034 //------------------------------------------------------------------------------- 00035 { 00036 gettimeofday(&end, NULL); 00037 } 00038 //------------------------------------------------------------------------------- 00039 00040 //------------------------------------------------------------------------------- 00041 inline float dureeCalcule() const 00042 //------------------------------------------------------------------------------- 00043 { 00044 return ((float)(end.tv_sec - begin.tv_sec) + (float)(end.tv_usec - begin.tv_usec) /1000000); 00045 } 00046 //------------------------------------------------------------------------------- 00047 00048 }; 00049 00050 #endif 00051 //-------------------------------------------------------------------------------