Go to the documentation of this file.00001
00002
00003
00004
00005 #include <assert.h>
00006
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
00019 _startTime = boost::posix_time::microsec_clock::local_time();
00020
00021
00022
00023 _startTimeLaunched = true;
00024 }
00025
00026
00027 double BasChronometer::elapsed () const {
00028 assert (_startTimeLaunched == true);
00029
00030
00031 const boost::posix_time::ptime lStopTime =
00032 boost::posix_time::microsec_clock::local_time();
00033
00034
00035 const boost::posix_time::time_duration lElapsedTime =
00036 lStopTime - _startTime;
00037
00038
00039 const double lElapsedTimeInMicroSeconds =
00040 static_cast<const double> (lElapsedTime.total_microseconds());
00041
00042
00043
00044
00045
00046
00047 return (lElapsedTimeInMicroSeconds / 1e6);
00048 }
00049
00050 }