diff options
Diffstat (limited to 'contrib/memscore/timestamp.h')
-rw-r--r-- | contrib/memscore/timestamp.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/memscore/timestamp.h b/contrib/memscore/timestamp.h new file mode 100644 index 000000000..fadb9cc8b --- /dev/null +++ b/contrib/memscore/timestamp.h @@ -0,0 +1,29 @@ +// memscore - in-memory phrase scoring for Statistical Machine Translation +// Christian Hardmeier, FBK-irst, Trento, 2010 +// $Id$ + +#ifndef TIMESTAMP_H +#define TIMESTAMP_H + +#include <sys/time.h> + +class Timestamp +{ +private: + struct timeval tv_; + +public: + typedef double time_difference; + + Timestamp() { + gettimeofday(&tv_, NULL); + } + + time_difference elapsed_time() const { + struct timeval tv2; + gettimeofday(&tv2, NULL); + return (tv2.tv_sec - tv_.tv_sec) * 1e6 + (tv2.tv_usec - tv_.tv_usec); + } +}; + +#endif |