2010-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_Time_H
|
|
|
|
#define moses_Time_H
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include "Util.h"
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
class Timer
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
friend std::ostream& operator<<(std::ostream& os, Timer& t);
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
private:
|
2008-06-11 14:52:57 +04:00
|
|
|
bool running;
|
|
|
|
time_t start_time;
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
// in seconds
|
2008-06-11 14:52:57 +04:00
|
|
|
double elapsed_time();
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
public:
|
2008-06-11 14:52:57 +04:00
|
|
|
/***
|
|
|
|
* 'running' is initially false. A timer needs to be explicitly started
|
|
|
|
* using 'start' or 'restart'
|
|
|
|
*/
|
|
|
|
Timer() : running(false), start_time(0) { }
|
|
|
|
|
|
|
|
void start(const char* msg = 0);
|
|
|
|
// void restart(const char* msg = 0);
|
|
|
|
// void stop(const char* msg = 0);
|
|
|
|
void check(const char* msg = 0);
|
|
|
|
double get_elapsed_time();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
|
|
|
|
2010-02-24 14:15:44 +03:00
|
|
|
#endif
|