1 //===- unittests/TimerTest.cpp - Timer tests ------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/Timer.h"
10 #include "gtest/gtest.h"
22 // FIXME: Put this somewhere in Support, it's also used in LockFileManager.
27 struct timespec Interval
;
29 Interval
.tv_nsec
= 1000000;
30 nanosleep(&Interval
, nullptr);
34 TEST(Timer
, Additivity
) {
37 EXPECT_TRUE(T1
.isInitialized());
41 auto TR1
= T1
.getTotalTime();
46 auto TR2
= T1
.getTotalTime();
51 TEST(Timer
, CheckIfTriggered
) {
54 EXPECT_FALSE(T1
.hasTriggered());
56 EXPECT_TRUE(T1
.hasTriggered());
58 EXPECT_TRUE(T1
.hasTriggered());
61 EXPECT_FALSE(T1
.hasTriggered());
64 } // end anon namespace