https://github.com/wilkeraziz/mosesdecoder
Tip revision: c55161dff40ef01fea15d6c0a8ed30b8ce1c7d46 authored by jiejiang on 16 January 2014, 01:08:01 UTC
merge c11 revert with mingw changes
merge c11 revert with mingw changes
Tip revision: c55161d
Timer.h
#ifndef moses_Time_H
#define moses_Time_H
#include <ctime>
#include <iostream>
#include <iomanip>
#include "Util.h"
namespace Moses
{
/** Wrapper around time_t to time how long things have been running
* according to walltime. We avoid CPU time since it is less reliable
* in a multi-threaded environment and can spuriously include clock cycles
* used by other threads in the same process.
*/
class Timer
{
friend std::ostream& operator<<(std::ostream& os, Timer& t);
private:
bool running;
bool stopped;
double start_time;
double stop_time;
public:
/***
* 'running' is initially false. A timer needs to be explicitly started
* using 'start'
*/
Timer() : running(false),stopped(false) {
start_time = 0;
}
void start(const char* msg = 0);
void stop(const char* msg = 0);
void check(const char* msg = 0);
double get_elapsed_time() const;
};
}
#endif