diff options
author | bothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-06 22:38:21 +0000 |
---|---|---|
committer | bothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-06 22:38:21 +0000 |
commit | 55da6f6d4e924769cea9463c1967e4405317a8c5 (patch) | |
tree | 3c2e99a39db8aea769378949d704bf6dfafe1056 /gi/pyp-topics/src/timing.h | |
parent | af33f7abb930c04c57f1422d14f976198cec6325 (diff) |
Added simple multi-threading during hyperparameter resampling. Added cmdarg for controlling number of threads. Moved Timer to its own header file. Cleaned up Makefile.am
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@170 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/pyp-topics/src/timing.h')
-rw-r--r-- | gi/pyp-topics/src/timing.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gi/pyp-topics/src/timing.h b/gi/pyp-topics/src/timing.h new file mode 100644 index 00000000..7543295c --- /dev/null +++ b/gi/pyp-topics/src/timing.h @@ -0,0 +1,31 @@ +#ifndef TIMING_H +#define TIMING_H + +#ifdef __CYGWIN__ +# ifndef _POSIX_MONOTONIC_CLOCK +# define _POSIX_MONOTONIC_CLOCK +# endif +#endif + +#include <time.h> +#include <sys/time.h> +#include "clock_gettime_stub.c" + +struct Timer { + Timer() { Reset(); } + void Reset() + { + clock_gettime(CLOCK_MONOTONIC, &start_t); + } + double Elapsed() const { + timespec end_t; + clock_gettime(CLOCK_MONOTONIC, &end_t); + const double elapsed = (end_t.tv_sec - start_t.tv_sec) + + (end_t.tv_nsec - start_t.tv_nsec) / 1000000000.0; + return elapsed; + } + private: + timespec start_t; +}; + +#endif |