This class implements a real-time timer. More...
#include <Util/Timer.H>
Public Member Functions | |
Timer (const int tickspersec=1000) | |
Constructor; immediately start timing. | |
void | reset () |
Reset the timer and immediately start timing again. | |
uint64 | get () const |
Return elapsed time. | |
uint64 | getReset () |
Return elapsed time since last reset, and reset. | |
int | ticksPerSec () const |
Returns number of ticks per second, as specified at construction. | |
double | getSecs () const |
Returns number of seconds since last reset. | |
double | getMilliSecs () const |
Returns number of milliseconds since last reset. | |
SimTime | getSimTime () const |
Returns the elapsed SimTime since last reset. | |
void | pause () |
Pause the timer. | |
void | resume () |
Resume the timer. | |
Protected Attributes | |
int64 | div |
time unit multipliers | |
int64 | mul |
struct timeval | tv |
timestamp of last reset() | |
int64 | offset |
timer offset of pause()/resume() | |
bool | pauseFlag |
This class implements a real-time timer.
Timing starts at construction or reset().
At construction, you can decide on a number of timer ticks per second; use 1000 to count in milliseconds, 1000000 to count in microseconds, etc. The best resolution achievable is 1us, as this timer relies on the gettimeofday() system call, which has microsecond resolution. Use get() to measure the number of elapsed ticks since last reset(), or getSecs() to get the fractional number of seconds. Use ticksPerSec() to retrieve this value, for example to convert yourself your measured times back to seconds instead of using getSecs().
Definition at line 58 of file Timer.H.
Timer::Timer | ( | const int | tickspersec = 1000 |
) | [inline] |
Constructor; immediately start timing.
tickspersec | number of timer ticks per second; use 1000 to count in milliseconds, 1000000 to count in microseconds, etc. Values larger than 1000000 will throw a fatal error. If 1000000/tickspersec is not integer, a fatal error will also occur. |
Definition at line 111 of file Timer.H.
References reset().
uint64 Timer::get | ( | ) | const [inline] |
Return elapsed time.
Return value is the number of ticks since last reset or since construction.
Definition at line 127 of file Timer.H.
References div, offset, and tv.
Referenced by LandmarkDB::build(), SingleChannelBeoServer::check(), SDLdisplay::displayYUVoverlay(), MotionSpatioTemporalChannel::doInput(), FaceDetector::evolve(), VisionBrainComponentI::evolve(), BeoLRF::evolve(), Beobot2GistSalMasterI::evolve(), BeoCamera::evolve(), GistSal_Navigation::evolve(), BeoPilot::evolve(), extractBitObjects(), featureClusterVision< FLOAT >::fCVclusterImage(), featureClusterVision< FLOAT >::fCVrunStandAloneMSBatchFilter(), featureClusterVision< FLOAT >::fCVrunStandAloneMSBatchTest(), featureClusterVision< FLOAT >::fCVsaccadeTest(), featureClusterVision< FLOAT >::fCVstandAloneFeatureTest(), Environment::load(), main(), NPclassify2< FLOAT >::NPclassifySpaceNew(), BeobotVisualCortex::processEnd(), processLocalizerResults(), EventLog::pushEvent(), Staircase::pushEvent(), IMU_MicroStrain_3DM_GX2::run(), CINNIC::RunSimpleImage(), BeobotControl::toSpeedLinear(), BeobotControl::toSpeedSigmoid(), VisionBrainComponentI::updateMessage(), Beobot2_GistSalLocalizerMasterI::updateMessage(), FaceDetector::updateMessage(), BeoLogger::updateMessage(), GistSal_Navigation::updateMessage(), SDLdisplay::waitNextRequestedFrameTime(), and SDLdisplay::waitNextRequestedVsync().
double Timer::getMilliSecs | ( | ) | const [inline] |
uint64 Timer::getReset | ( | ) | [inline] |
Return elapsed time since last reset, and reset.
Definition at line 138 of file Timer.H.
Referenced by BotControl::getImageSensor(), main(), and MapperI::updateMessage().
double Timer::getSecs | ( | ) | const [inline] |
Returns number of seconds since last reset.
Definition at line 152 of file Timer.H.
References tv.
Referenced by RegSaliency::doInput(), SeaBee3GUIIce::evolve(), WaypointControllerI::evolve(), BeoPilot::evolve(), CudaHmaxFL::getC2(), getData(), getSimTime(), BeoSub::getTime(), main(), plotData(), Serial::readFrame(), Beowulf::receive(), BeoSubOneBal::setBallasts(), EyeTrackerUDP::start2(), BeoSubSim::updateCompass(), BeoSubOneBal::updateCompass(), BeoSubOneBal::updateDepth(), BeoSubSim::updateDepth(), SDLdisplay::waitForKeyTimeout(), and BeoSub::waitMove().
SimTime Timer::getSimTime | ( | ) | const [inline] |
Returns the elapsed SimTime since last reset.
Definition at line 168 of file Timer.H.
References getSecs(), and SimTime::SECS().
Referenced by BeoSub::getSaliencyMap(), and main().
void Timer::pause | ( | ) | [inline] |
Pause the timer.
Definition at line 174 of file Timer.H.
References offset.
Referenced by BeoPilot::evolve().
void Timer::reset | ( | void | ) | [inline] |
Reset the timer and immediately start timing again.
Definition at line 120 of file Timer.H.
Referenced by LandmarkDB::build(), NPclassify::classifySpaceNew(), RegSaliency::doInput(), FaceDetector::evolve(), QT_Navigation::evolve(), SeaBee3GUIIce::evolve(), CornerNavigation::evolve(), BeoLRF::evolve(), Beobot2GistSalMasterI::evolve(), BeoCamera::evolve(), GistSal_Navigation::evolve(), BeoIMU::evolve(), BeoPilot::evolve(), Gist_Navigation::evolve(), extractBitObjects(), featureClusterVision< FLOAT >::fCVclusterImage(), featureClusterVision< FLOAT >::fCVrunStandAloneMSBatchFilter(), featureClusterVision< FLOAT >::fCVrunStandAloneMSBatchTest(), featureClusterVision< FLOAT >::fCVsaccadeTest(), featureClusterVision< FLOAT >::fCVstandAloneFeatureTest(), CudaHmaxFL::getC2(), getData(), FoeDetector::getFoe(), BotControl::init(), Environment::load(), BeoPilot::loadFromLogFile(), main(), NPclassify2< FLOAT >::NPclassifySpaceNew(), processLocalizerResults(), BeobotControl::rampSpeed(), Serial::readFrame(), Staircase::reset1(), Beowulf::resetConnections(), IMU_MicroStrain_3DM_GX2::run(), CudaSaliency::runSaliency(), RegSaliency::runSaliency(), CINNIC::RunSimpleImage(), Beobot2GistSalMasterI::start1(), BeoLogger::start1(), FaceDetector::start1(), EventLog::start1(), GistSal_Grapher::start1(), SDLdisplay::start2(), Staircase::start2(), Timer(), WaypointControllerI::updateMessage(), VisionBrainComponentI::updateMessage(), BeoPilot::updateMessage(), and SDLdisplay::waitNextRequestedFrameTime().
void Timer::resume | ( | ) | [inline] |
Resume the timer.
Definition at line 182 of file Timer.H.
References tv.
Referenced by BeoPilot::evolve().
int Timer::ticksPerSec | ( | ) | const [inline] |
int64 Timer::div [protected] |
int64 Timer::offset [protected] |
struct timeval Timer::tv [protected] |
timestamp of last reset()
Definition at line 101 of file Timer.H.
Referenced by get(), getMilliSecs(), getReset(), getSecs(), reset(), and resume().