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
path: root/mert
diff options
context:
space:
mode:
authorJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-04-22 08:45:41 +0300
committerJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-04-22 08:45:41 +0300
commit1083999d3e4447ac347b8bcbb04a0733ae8c3654 (patch)
treef3b2de6aa564d31428a83dbcc2065c9827bd9147 /mert
parent02d1d9a4af94ad148521fa934e802561e9b685a3 (diff)
Adapt test to poor Windows timer resolution.
TimerTest fails on Windows unless the sleep time is set to at least a millisecond (1,000 microseconds). Keep it nice and low for other platforms though, because the sleep time is wasted.
Diffstat (limited to 'mert')
-rw-r--r--mert/TimerTest.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/mert/TimerTest.cpp b/mert/TimerTest.cpp
index d72b1c312..532e44fc1 100644
--- a/mert/TimerTest.cpp
+++ b/mert/TimerTest.cpp
@@ -11,7 +11,20 @@ using namespace MosesTuning;
BOOST_AUTO_TEST_CASE(timer_basic_test)
{
Timer timer;
- const int sleep_time_microsec = 40; // ad-hoc microseconds to pass unit tests.
+
+ // Sleep time. The test will sleep for this number of microseconds, and
+ // expect the elapsed time to be noticeable.
+ // Keep this number low to avoid wasting test time sleeping, but at least as
+ // high as the Boost timer's resolution. Tests must pass consistently, not
+ // just on lucky runs.
+#if defined(WIN32)
+ // Timer resolution on Windows seems to be a millisecond. Anything less and
+ // the test fails consistently.
+ const int sleep_time_microsec = 1000;
+#else
+ // Unix-like systems seem to have more fine-grained clocks.
+ const int sleep_time_microsec = 40;
+#endif
timer.start();
BOOST_REQUIRE(timer.is_running());