1 //===- unittests/TimerTest.cpp - Timer tests ------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/Timer.h"
11 #include "gtest/gtest.h"
23 // FIXME: Put this somewhere in Support, it's also used in LockFileManager.
28 struct timespec Interval
;
30 Interval
.tv_nsec
= 1000000;
31 nanosleep(&Interval
, nullptr);
35 TEST(Timer
, Additivity
) {
38 EXPECT_TRUE(T1
.isInitialized());
42 auto TR1
= T1
.getTotalTime();
47 auto TR2
= T1
.getTotalTime();
49 EXPECT_TRUE(TR1
< TR2
);
52 TEST(Timer
, CheckIfTriggered
) {
55 EXPECT_FALSE(T1
.hasTriggered());
57 EXPECT_TRUE(T1
.hasTriggered());
59 EXPECT_TRUE(T1
.hasTriggered());
62 EXPECT_FALSE(T1
.hasTriggered());
65 } // end anon namespace