aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/TimerTest.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-12-23 01:04:53 +0000
committerNico Weber <nicolasweber@gmx.de>2015-12-23 01:04:53 +0000
commit07e602e6bbcfb9fba96cdead2893d1648392607e (patch)
tree3170ca0ec17742e5cf649eef0472b7358d8f222d /llvm/unittests/Support/TimerTest.cpp
parent95ef4b3bf0a8520f9bba4d4ab2583db593f84740 (diff)
downloadllvm-07e602e6bbcfb9fba96cdead2893d1648392607e.zip
llvm-07e602e6bbcfb9fba96cdead2893d1648392607e.tar.gz
llvm-07e602e6bbcfb9fba96cdead2893d1648392607e.tar.bz2
Unbreak LLVM_ENABLE_THREADS=OFF builds.
llvm-svn: 256308
Diffstat (limited to 'llvm/unittests/Support/TimerTest.cpp')
-rw-r--r--llvm/unittests/Support/TimerTest.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/unittests/Support/TimerTest.cpp b/llvm/unittests/Support/TimerTest.cpp
index 00515f9..f556a3f 100644
--- a/llvm/unittests/Support/TimerTest.cpp
+++ b/llvm/unittests/Support/TimerTest.cpp
@@ -8,14 +8,30 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Timer.h"
-#include "llvm/Support/thread.h"
#include "gtest/gtest.h"
-#include <chrono>
+
+#if LLVM_ON_WIN32
+#include <windows.h>
+#else
+#include <time.h>
+#endif
using namespace llvm;
namespace {
+// FIXME: Put this somewhere in Support, it's also used in LockFileManager.
+void SleepMS() {
+#if LLVM_ON_WIN32
+ Sleep(1);
+#else
+ struct timespec Interval;
+ Interval.tv_sec = 0;
+ Interval.tv_nsec = 1000000;
+ nanosleep(&Interval, nullptr);
+#endif
+}
+
TEST(Timer, Additivity) {
Timer T1("T1");
@@ -26,7 +42,7 @@ TEST(Timer, Additivity) {
auto TR1 = T1.getTotalTime();
T1.startTimer();
- std::this_thread::sleep_for(std::chrono::milliseconds(1));
+ SleepMS();
T1.stopTimer();
auto TR2 = T1.getTotalTime();