llvm.org GIT mirror llvm / 20aab1c
Unbreak LLVM_ENABLE_THREADS=OFF builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256308 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 3 years ago
1 changed file(s) with 19 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/Support/Timer.h"
10 #include "llvm/Support/thread.h"
1110 #include "gtest/gtest.h"
12 #include
11
12 #if LLVM_ON_WIN32
13 #include
14 #else
15 #include
16 #endif
1317
1418 using namespace llvm;
1519
1620 namespace {
21
22 // FIXME: Put this somewhere in Support, it's also used in LockFileManager.
23 void SleepMS() {
24 #if LLVM_ON_WIN32
25 Sleep(1);
26 #else
27 struct timespec Interval;
28 Interval.tv_sec = 0;
29 Interval.tv_nsec = 1000000;
30 nanosleep(&Interval, nullptr);
31 #endif
32 }
1733
1834 TEST(Timer, Additivity) {
1935 Timer T1("T1");
2541 auto TR1 = T1.getTotalTime();
2642
2743 T1.startTimer();
28 std::this_thread::sleep_for(std::chrono::milliseconds(1));
44 SleepMS();
2945 T1.stopTimer();
3046 auto TR2 = T1.getTotalTime();
3147