summaryrefslogtreecommitdiff
path: root/gi/pyp-topics
diff options
context:
space:
mode:
authorphilblunsom <philblunsom@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 14:54:18 +0000
committerphilblunsom <philblunsom@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 14:54:18 +0000
commita3cd7e5a7f85271aa222cd42088a716417e6244c (patch)
tree7bb9213c3edd9cbb3c72bfcd737ab4966d3e0645 /gi/pyp-topics
parent595dd3f0e577f522d32318acb2ad0fe288e0b00f (diff)
Undid timer changes, will have to think of something else ...
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@104 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/pyp-topics')
-rw-r--r--gi/pyp-topics/src/contexts_corpus.cc2
-rw-r--r--gi/pyp-topics/src/pyp-topics.cc46
2 files changed, 24 insertions, 24 deletions
diff --git a/gi/pyp-topics/src/contexts_corpus.cc b/gi/pyp-topics/src/contexts_corpus.cc
index c09188af..f01d352a 100644
--- a/gi/pyp-topics/src/contexts_corpus.cc
+++ b/gi/pyp-topics/src/contexts_corpus.cc
@@ -35,7 +35,7 @@ void read_callback(const ContextsLexer::PhraseContextsType& new_contexts, void*
// filter out singleton contexts
if (!counts->empty()) {
map<string,int>::const_iterator find_it = counts->find(context_str);
- if (find_it == counts->end() || find_it->second < 1)
+ if (find_it == counts->end() || find_it->second < 2)
continue;
}
diff --git a/gi/pyp-topics/src/pyp-topics.cc b/gi/pyp-topics/src/pyp-topics.cc
index 796ab7af..97f50362 100644
--- a/gi/pyp-topics/src/pyp-topics.cc
+++ b/gi/pyp-topics/src/pyp-topics.cc
@@ -3,40 +3,40 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <sys/time.h>
-#include <mach/mach_time.h>
+//#include <mach/mach_time.h>
struct Timer {
Timer() { Reset(); }
void Reset()
{
- //clock_gettime(CLOCK_MONOTONIC, &start_t);
- start_t = mach_absolute_time();
+ clock_gettime(CLOCK_MONOTONIC, &start_t);
+ //start_t = mach_absolute_time();
}
double Elapsed() const {
- //timespec end_t;
- timespec tp;
- uint64_t end_t = mach_absolute_time();
- mach_absolute_difference(end_t, start_t, &tp);
- //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;
- const double elapsed = tp.tv_sec + tp.tv_nsec / 1000000000.0;
+ timespec end_t;
+ //timespec tp;
+ //uint64_t end_t = mach_absolute_time();
+ //mach_absolute_difference(end_t, start_t, &tp);
+ 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;
+ //const double elapsed = tp.tv_sec + tp.tv_nsec / 1000000000.0;
return elapsed;
}
private:
- void mach_absolute_difference(uint64_t end, uint64_t start, struct timespec *tp) const {
- uint64_t difference = end - start;
- static mach_timebase_info_data_t info = {0,0};
-
- if (info.denom == 0)
- mach_timebase_info(&info);
- uint64_t elapsednano = difference * (info.numer / info.denom);
- tp->tv_sec = elapsednano * 1e-9;
- tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9);
- }
- //timespec start_t;
- uint64_t start_t;
+// void mach_absolute_difference(uint64_t end, uint64_t start, struct timespec *tp) const {
+// uint64_t difference = end - start;
+// static mach_timebase_info_data_t info = {0,0};
+//
+// if (info.denom == 0)
+// mach_timebase_info(&info);
+// uint64_t elapsednano = difference * (info.numer / info.denom);
+// tp->tv_sec = elapsednano * 1e-9;
+// tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9);
+// }
+ timespec start_t;
+ //uint64_t start_t;
};
void PYPTopics::sample(const Corpus& corpus, int samples) {