Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2014-01-02 01:19:06 +0400
committerKenneth Heafield <github@kheafield.com>2014-01-02 01:19:06 +0400
commit732a1b074426352498fc99459ae8499d95690084 (patch)
tree56a06f19e341260128faf60743e84506943e9c07 /moses/Timer.cpp
parent18aaf4750a11f7a903a143b83f51eb34323613ea (diff)
KenLM 85c82bd, revamp Moses timer to have more precision
Diffstat (limited to 'moses/Timer.cpp')
-rw-r--r--moses/Timer.cpp66
1 files changed, 8 insertions, 58 deletions
diff --git a/moses/Timer.cpp b/moses/Timer.cpp
index bbe1bcabd..d1f6c4b8b 100644
--- a/moses/Timer.cpp
+++ b/moses/Timer.cpp
@@ -1,35 +1,20 @@
-#include <ctime>
#include <iostream>
#include <iomanip>
#include "Util.h"
#include "Timer.h"
-namespace Moses
-{
+#include "util/usage.hh"
-/***
- * Return the total time that the timer has been in the "running"
- * state since it was first "started" or last "restarted". For
- * "short" time periods (less than an hour), the actual cpu time
- * used is reported instead of the elapsed time.
- */
-double Timer::elapsed_time()
+namespace Moses
{
- time_t now;
- time(&now);
- return difftime(now, start_time);
-}
/***
- * Return the total time that the timer has been in the "running"
- * state since it was first "started" or last "restarted". For
- * "short" time periods (less than an hour), the actual cpu time
- * used is reported instead of the elapsed time.
- * This function is the public version of elapsed_time()
+ * Return the total wall time that the timer has been in the "running"
+ * state since it was first "started".
*/
double Timer::get_elapsed_time()
{
- return elapsed_time();
+ return util::WallTime() - start_time;
}
/***
@@ -47,44 +32,9 @@ void Timer::start(const char* msg)
// Change timer status to running
running = true;
- // Set the start time;
- time(&start_time);
-}
-
-/***
- * Turn the timer off and start it again from 0. Print an optional message.
- */
-/*
-inline void Timer::restart(const char* msg)
-{
- // Print an optional message, something like "Restarting timer t";
- if (msg) TRACE_ERR( msg << std::endl;
-
- // Set the timer status to running
- running = true;
-
- // Set the accumulated time to 0 and the start time to now
- acc_time = 0;
- start_clock = clock();
- start_time = time(0);
+ start_time = util::WallTime();
}
-*/
-
-/***
- * Stop the timer and print an optional message.
- */
-/*
-inline void Timer::stop(const char* msg)
-{
- // Print an optional message, something like "Stopping timer t";
- check(msg);
- // Recalculate and store the total accumulated time up until now
- if (running) acc_time += elapsed_time();
-
- running = false;
-}
-*/
/***
* Print out an optional message followed by the current timer timing.
*/
@@ -94,7 +44,7 @@ void Timer::check(const char* msg)
if (msg) TRACE_ERR( msg << " : ");
// TRACE_ERR( "[" << std::setiosflags(std::ios::fixed) << std::setprecision(2) << (running ? elapsed_time() : 0) << "] seconds\n");
- TRACE_ERR( "[" << (running ? elapsed_time() : 0) << "] seconds\n");
+ TRACE_ERR( "[" << (running ? get_elapsed_time() : 0) << "] seconds\n");
}
/***
@@ -105,7 +55,7 @@ void Timer::check(const char* msg)
std::ostream& operator<<(std::ostream& os, Timer& t)
{
//os << std::setprecision(2) << std::setiosflags(std::ios::fixed) << (t.running ? t.elapsed_time() : 0);
- os << (t.running ? t.elapsed_time() : 0);
+ os << (t.running ? t.get_elapsed_time() : 0);
return os;
}