WallclockTimer added
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1673 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
55
src/core/util/WallclockTimer.hpp
Normal file
55
src/core/util/WallclockTimer.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* \brief The WallclockTimer measures the elapsed time
|
||||
*
|
||||
* The WallclockTimer measures the time which is elapsed between start and stop of the timer.
|
||||
*/
|
||||
|
||||
#ifndef __WALLCLOCKTIMER_HPP__
|
||||
#define __WALLCLOCKTIMER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class WallclockTimer
|
||||
*
|
||||
* 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,current;
|
||||
Logger m_log;
|
||||
|
||||
public:
|
||||
WallclockTimer();
|
||||
virtual ~WallclockTimer() { }
|
||||
/**
|
||||
* Starts the timer.
|
||||
*/
|
||||
void startTimer();
|
||||
/**
|
||||
* Returns the elapsed time. This works while the timer is running, and if it is stopped.
|
||||
*/
|
||||
std::string getRuntime();
|
||||
/**
|
||||
* Stops the timer.
|
||||
*/
|
||||
void stopTimer();
|
||||
/**
|
||||
* Resets the timer. The timer is after a call of reset stopped.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __WALLCLOCKTIMER_HPP__
|
||||
Reference in New Issue
Block a user