summaryrefslogtreecommitdiff
path: root/gi/pyp-topics
diff options
context:
space:
mode:
authorbothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 02:47:27 +0000
committerbothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 02:47:27 +0000
commit47b1a9afff62ceb56cbac7a98fcebb355405db6a (patch)
tree55fd7cbcb5e9ab78883fd40103f54be238548cfe /gi/pyp-topics
parent3e5d3112c3b2b3b4a2114e1da13cfa91498be404 (diff)
changed timer mechanism to play nice with multiple threads
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@99 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/pyp-topics')
-rw-r--r--gi/pyp-topics/src/pyp-topics.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/gi/pyp-topics/src/pyp-topics.cc b/gi/pyp-topics/src/pyp-topics.cc
index 0f13cd35..d8a8d815 100644
--- a/gi/pyp-topics/src/pyp-topics.cc
+++ b/gi/pyp-topics/src/pyp-topics.cc
@@ -1,21 +1,28 @@
#include "pyp-topics.hh"
//#include "mt19937ar.h"
-#include <ctime>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <sys/time.h>
struct Timer {
Timer() { Reset(); }
- void Reset() { start_t = clock(); }
+ void Reset()
+ {
+ clock_gettime(CLOCK_MONOTONIC, &start_t);
+ }
double Elapsed() const {
- const clock_t end_t = clock();
- const double elapsed = (end_t - start_t) / 1000000.0;
+ 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:
- std::clock_t start_t;
+ timespec start_t;
};
-
void PYPTopics::sample(const Corpus& corpus, int samples) {
Timer timer;