00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // C 00005 #include <assert.h> 00006 // Rmol 00007 #include <rmol/basic/BasChronometer.hpp> 00008 #include <rmol/service/Logger.hpp> 00009 00010 namespace RMOL { 00011 00012 // ////////////////////////////////////////////////////////////////////// 00013 BasChronometer::BasChronometer () : _startTimeLaunched (false) { 00014 } 00015 00016 // ////////////////////////////////////////////////////////////////////// 00017 void BasChronometer::start () { 00018 // Get the time-stamp of now, and store it for later use 00019 _startTime = boost::posix_time::microsec_clock::local_time(); 00020 00021 // Update the boolean which states whether the chronometer 00022 // is launched 00023 _startTimeLaunched = true; 00024 } 00025 00026 // ////////////////////////////////////////////////////////////////////// 00027 double BasChronometer::elapsed () const { 00028 assert (_startTimeLaunched == true); 00029 00030 // Get the time-stamp of now 00031 const boost::posix_time::ptime lStopTime = 00032 boost::posix_time::microsec_clock::local_time(); 00033 00034 // Calculate the time elapsed since the last time-stamp 00035 const boost::posix_time::time_duration lElapsedTime = 00036 lStopTime - _startTime; 00037 00038 // Derived the corresponding number of milliseconds 00039 const double lElapsedTimeInMicroSeconds = 00040 static_cast<const double> (lElapsedTime.total_microseconds()); 00041 00042 /*RMOL_LOG_DEBUG ("Elapsed: " << lElapsedTime 00043 << "; (micros): " 00044 << lElapsedTimeInMicroSeconds / 1e6);*/ 00045 00046 // The elapsed time given in return is expressed in seconds 00047 return (lElapsedTimeInMicroSeconds / 1e6); 00048 } 00049 00050 }
Generated on Tue Sep 7 2010 18:38:31 for RMOL by Doxygen 1.7.1