mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-17 07:20:48 +03:00
move global Timer to Timer.h
Move ResetUserTime(), PrintUserTime(), GetUserTime() to Timer.h Do not reset timer in StaticData.
This commit is contained in:
parent
0dd6c31f63
commit
3b63930943
@ -25,6 +25,7 @@
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/Util.h"
|
||||
#include "OnDiskWrapper.h"
|
||||
#include "SourcePhrase.h"
|
||||
|
@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "Decoder.h"
|
||||
#include "moses/Manager.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/ChartManager.h"
|
||||
#include "moses/Sentence.h"
|
||||
#include "moses/InputType.h"
|
||||
@ -74,6 +75,7 @@ MosesDecoder::MosesDecoder(const string& inifile, int debuglevel, int argc, vect
|
||||
cerr << "Loading static data failed, exit." << endl;
|
||||
exit(1);
|
||||
}
|
||||
ResetUserTime();
|
||||
StaticData::LoadDataStatic(params, "mira");
|
||||
for (int i = 0; i < BASE_ARGC; ++i) {
|
||||
delete[] mosesargv[i];
|
||||
|
@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "IOWrapper.h"
|
||||
#include "LatticeMBR.h"
|
||||
#include "Manager.h"
|
||||
#include "Timer.h"
|
||||
#include "StaticData.h"
|
||||
|
||||
#include "util/exception.hh"
|
||||
@ -152,6 +153,7 @@ int main(int argc, char* argv[])
|
||||
params->Explain();
|
||||
exit(1);
|
||||
}
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(params, argv[0])) {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "IOWrapper.h"
|
||||
#include "StaticData.h"
|
||||
#include "Util.h"
|
||||
#include "Timer.h"
|
||||
#include "ThreadPool.h"
|
||||
#include "TranslationAnalysis.h"
|
||||
#include "OutputCollector.h"
|
||||
@ -191,6 +192,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// initialize all "global" variables, which are stored in StaticData
|
||||
// note: this also loads models such as the language model, etc.
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(params, argv[0])) {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "moses/InputPath.h"
|
||||
#include "moses/Parameter.h"
|
||||
#include "moses/TranslationModel/PhraseDictionary.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/StaticData.h"
|
||||
|
||||
#include "util/file_piece.hh"
|
||||
@ -150,6 +151,7 @@ int main(int argc, char const** argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(params.get(),argv[0])) {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "moses/IOWrapper.h"
|
||||
#include "moses/LatticeMBR.h"
|
||||
#include "moses/Manager.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/StaticData.h"
|
||||
#include "util/exception.hh"
|
||||
|
||||
@ -155,6 +156,8 @@ int main(int argc, char const* argv[])
|
||||
params->Explain();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(params, argv[0])) {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ int main(int argc, char const** argv)
|
||||
|
||||
// initialize all "global" variables, which are stored in StaticData
|
||||
// note: this also loads models such as the language model, etc.
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(¶ms, argv[0])) {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ SimpleTranslationInterface::SimpleTranslationInterface(const string &mosesIni):
|
||||
cerr << "Error; Cannot load parameters at " << mosesIni<<endl;
|
||||
exit(1);
|
||||
}
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(&m_params, mosesIni.c_str())) {
|
||||
cerr << "Error; Cannot load static data in file " << mosesIni<<endl;
|
||||
exit(1);
|
||||
@ -317,6 +318,7 @@ int decoder_main(int argc, char const** argv)
|
||||
|
||||
// initialize all "global" variables, which are stored in StaticData
|
||||
// note: this also loads models such as the language model, etc.
|
||||
ResetUserTime();
|
||||
if (!StaticData::LoadDataStatic(¶ms, argv[0]))
|
||||
exit(1);
|
||||
|
||||
|
@ -303,7 +303,6 @@ ini_zombie_options()
|
||||
|
||||
bool StaticData::LoadData(Parameter *parameter)
|
||||
{
|
||||
ResetUserTime();
|
||||
m_parameter = parameter;
|
||||
|
||||
const PARAM_VEC *params;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "moses/FactorCollection.h"
|
||||
#include "moses/Word.h"
|
||||
#include "moses/Util.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/StaticData.h"
|
||||
#include "moses/Range.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "moses/FactorCollection.h"
|
||||
#include "moses/Word.h"
|
||||
#include "moses/Util.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/StaticData.h"
|
||||
#include "moses/Range.h"
|
||||
|
@ -9,6 +9,26 @@
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
//global variable
|
||||
Timer g_timer;
|
||||
|
||||
|
||||
void ResetUserTime()
|
||||
{
|
||||
g_timer.start();
|
||||
};
|
||||
|
||||
void PrintUserTime(const std::string &message)
|
||||
{
|
||||
g_timer.check(message.c_str());
|
||||
}
|
||||
|
||||
double GetUserTime()
|
||||
{
|
||||
return g_timer.get_elapsed_time();
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Return the total wall time that the timer has been in the "running"
|
||||
* state since it was first "started".
|
||||
|
@ -9,6 +9,21 @@
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
// A couple of utilities to measure decoding time
|
||||
|
||||
/** Start global timer. */
|
||||
void ResetUserTime();
|
||||
|
||||
/** Print out an optional message followed by the current global timer timing. */
|
||||
void PrintUserTime(const std::string &message);
|
||||
|
||||
/**
|
||||
* Total wall time that the global timer has been in the "running"
|
||||
* state since it was first "started".
|
||||
*/
|
||||
double GetUserTime();
|
||||
|
||||
|
||||
/** Wrapper around time_t to time how long things have been running
|
||||
* according to walltime. We avoid CPU time since it is less reliable
|
||||
* in a multi-threaded environment and can spuriously include clock cycles
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "moses/AlignmentInfoCollection.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/Util.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/Word.h"
|
||||
#include "Trie.h"
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "moses/TranslationAnalysis.h"
|
||||
#include "moses/TypeDef.h"
|
||||
#include "moses/Util.h"
|
||||
#include "moses/Timer.h"
|
||||
#include "moses/InputType.h"
|
||||
#include "moses/OutputCollector.h"
|
||||
#include "moses/Incremental.h"
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include "TypeDef.h"
|
||||
#include "Util.h"
|
||||
#include "Timer.h"
|
||||
//#include "Timer.h"
|
||||
#include "util/exception.hh"
|
||||
#include "util/file.hh"
|
||||
#include "moses/FF/StatelessFeatureFunction.h"
|
||||
@ -48,8 +48,6 @@ using namespace boost::algorithm;
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
//global variable
|
||||
Timer g_timer;
|
||||
|
||||
string GetTempFolder()
|
||||
{
|
||||
@ -90,21 +88,6 @@ bool FileExists(const std::string& filePath)
|
||||
return !ifs.fail();
|
||||
}
|
||||
|
||||
void ResetUserTime()
|
||||
{
|
||||
g_timer.start();
|
||||
};
|
||||
|
||||
void PrintUserTime(const std::string &message)
|
||||
{
|
||||
g_timer.check(message.c_str());
|
||||
}
|
||||
|
||||
double GetUserTime()
|
||||
{
|
||||
return g_timer.get_elapsed_time();
|
||||
}
|
||||
|
||||
std::vector< std::map<std::string, std::string> > ProcessAndStripDLT(std::string &line)
|
||||
{
|
||||
std::vector< std::map<std::string, std::string> > meta;
|
||||
|
@ -466,11 +466,6 @@ inline void ShrinkToFit(T& v)
|
||||
|
||||
bool FileExists(const std::string& filePath);
|
||||
|
||||
// A couple of utilities to measure decoding time
|
||||
void ResetUserTime();
|
||||
void PrintUserTime(const std::string &message);
|
||||
double GetUserTime();
|
||||
|
||||
// dump SGML parser for <dlt> tags
|
||||
std::vector< std::map<std::string, std::string> > ProcessAndStripDLT(std::string &line);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user