WallclockTimer: coding style unifications.
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1867 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
/**
|
||||
* \brief The WallclockTimer measures the elapsed time
|
||||
*
|
||||
* The WallclockTimer measures the time which is elapsed between start and stop of the timer.
|
||||
* The WallclockTimer measures the time which is elapsed between start
|
||||
* and stop of the timer.
|
||||
*/
|
||||
|
||||
#ifndef __WALLCLOCKTIMER_HPP__
|
||||
@ -11,51 +12,57 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class WallclockTimer
|
||||
*
|
||||
* The class WallclockTimer contains all functions for start, stop, reset and to get the elapsed
|
||||
* time.
|
||||
* The class WallclockTimer contains all functions for start,
|
||||
* stop, reset and to get the elapsed time.
|
||||
*/
|
||||
class WallclockTimer {
|
||||
private:
|
||||
|
||||
bool isRunning;
|
||||
struct timeval start,end;
|
||||
|
||||
bool m_IsRunning;
|
||||
struct timeval m_Start, m_End;
|
||||
public:
|
||||
WallclockTimer();
|
||||
WallclockTimer() : m_IsRunning(false) { }
|
||||
virtual ~WallclockTimer() { }
|
||||
/**
|
||||
* Starts the timer.
|
||||
* Starts the timer.
|
||||
*/
|
||||
void startTimer();
|
||||
/**
|
||||
* Returns the elapsed time as string. This works while the timer is running, and if it is stopped.
|
||||
* Returns the elapsed time as \c std::string. This works while the timer
|
||||
* is running, and if it is stopped.
|
||||
*/
|
||||
std::string getRuntimeAsString() const;
|
||||
/**
|
||||
* Returns the elapsed time as double. This works while the timer is running, and if it is stopped.
|
||||
* Returns the elapsed time as \c double. This works while the timer
|
||||
* is running, and if it is stopped.
|
||||
*/
|
||||
double getRuntimeAsDouble() const;
|
||||
/**
|
||||
* Stops the timer.
|
||||
* Stops the timer.
|
||||
*/
|
||||
void stopTimer();
|
||||
/**
|
||||
* Resets the timer. The timer is after a call of reset stopped.
|
||||
* Resets the timer. The timer is stopped after calling reset().
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Returns the elapsed time as \c double. This works while the
|
||||
* timer is running, and if it is stopped.
|
||||
*/
|
||||
operator double() { return getRuntimeAsDouble(); }
|
||||
|
||||
operator int() { return ((int) getRuntimeAsDouble()); }
|
||||
/**
|
||||
* Returns the elapsed time as \c int. This works while the timer
|
||||
* is running, and if it is stopped.
|
||||
*/
|
||||
operator int() { return (int)getRuntimeAsDouble(); }
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const WallclockTimer& w);
|
||||
std::ostream& operator<< (std::ostream& os, const WallclockTimer& w)
|
||||
{ return os << w.getRuntimeAsString(); }
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
|
||||
Reference in New Issue
Block a user