diff options
Diffstat (limited to 'moses/src/Timer.h')
-rw-r--r-- | moses/src/Timer.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/moses/src/Timer.h b/moses/src/Timer.h new file mode 100644 index 000000000..a46250143 --- /dev/null +++ b/moses/src/Timer.h @@ -0,0 +1,39 @@ +#ifndef TIMER_H +#define TIMER_H + +#include <ctime> +#include <iostream> +#include <iomanip> + +namespace Moses +{ + +class Timer +{ + friend std::ostream& operator<<(std::ostream& os, Timer& t); + + private: + bool running; + time_t start_time; + + //TODO in seconds? + double elapsed_time(); + + public: + /*** + * '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(); + +}; + +} + +#endif // TIMER_H |