summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
Diffstat (limited to 'gi')
-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;