mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
Tetsuo's two patches
This commit is contained in:
parent
b5bb500773
commit
59bd7deb4b
@ -25,7 +25,7 @@ uint64_t HashForVocab(const char *str, std::size_t len);
|
|||||||
inline uint64_t HashForVocab(const StringPiece &str) {
|
inline uint64_t HashForVocab(const StringPiece &str) {
|
||||||
return HashForVocab(str.data(), str.length());
|
return HashForVocab(str.data(), str.length());
|
||||||
}
|
}
|
||||||
class ProbingVocabularyHeader;
|
struct ProbingVocabularyHeader;
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
class WriteWordsWrapper : public EnumerateVocab {
|
class WriteWordsWrapper : public EnumerateVocab {
|
||||||
|
@ -21,6 +21,21 @@ namespace util {
|
|||||||
|
|
||||||
#if !defined(_WIN32) && !defined(_WIN64)
|
#if !defined(_WIN32) && !defined(_WIN64)
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
// On Mac OS X, clock_gettime is not implemented.
|
||||||
|
// CLOCK_MONOTONIC is not defined either.
|
||||||
|
#ifdef __MACH__
|
||||||
|
#define CLOCK_MONOTONIC 0
|
||||||
|
|
||||||
|
int clock_gettime(int clk_id, struct timespec *tp) {
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
tp->tv_sec = tv.tv_sec;
|
||||||
|
tp->tv_nsec = tv.tv_usec * 1000;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif // __MACH__
|
||||||
|
|
||||||
float FloatSec(const struct timeval &tv) {
|
float FloatSec(const struct timeval &tv) {
|
||||||
return static_cast<float>(tv.tv_sec) + (static_cast<float>(tv.tv_usec) / 1000000.0);
|
return static_cast<float>(tv.tv_sec) + (static_cast<float>(tv.tv_usec) / 1000000.0);
|
||||||
}
|
}
|
||||||
@ -36,9 +51,7 @@ const char *SkipSpaces(const char *at) {
|
|||||||
class RecordStart {
|
class RecordStart {
|
||||||
public:
|
public:
|
||||||
RecordStart() {
|
RecordStart() {
|
||||||
#ifdef CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &started_);
|
clock_gettime(CLOCK_MONOTONIC, &started_);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct timespec &Started() const {
|
const struct timespec &Started() const {
|
||||||
@ -79,9 +92,7 @@ void PrintUsage(std::ostream &out) {
|
|||||||
out << "CPU:" << (FloatSec(usage.ru_utime) + FloatSec(usage.ru_stime));
|
out << "CPU:" << (FloatSec(usage.ru_utime) + FloatSec(usage.ru_stime));
|
||||||
|
|
||||||
struct timespec current;
|
struct timespec current;
|
||||||
#ifdef CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, ¤t);
|
clock_gettime(CLOCK_MONOTONIC, ¤t);
|
||||||
#endif
|
|
||||||
out << "\treal:" << (FloatSec(current) - FloatSec(kRecordStart.Started())) << '\n';
|
out << "\treal:" << (FloatSec(current) - FloatSec(kRecordStart.Started())) << '\n';
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user