diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:57 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:57 +0000 |
commit | 88c643b6fec27eec436c8d138fee6346e92337d6 (patch) | |
tree | 82cd13b2f3cde1c9e5f79689ba4e6ba67694843f /unittests/Utility/TimerTest.cpp | |
parent | 94994d372d014ce4c8758b9605d63fae651bd8aa (diff) |
Notes
Diffstat (limited to 'unittests/Utility/TimerTest.cpp')
-rw-r--r-- | unittests/Utility/TimerTest.cpp | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/unittests/Utility/TimerTest.cpp b/unittests/Utility/TimerTest.cpp deleted file mode 100644 index 04b715915bff..000000000000 --- a/unittests/Utility/TimerTest.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===-- TimerTest.cpp -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Utility/StreamString.h" -#include "lldb/Utility/Timer.h" -#include "gtest/gtest.h" -#include <thread> - -using namespace lldb_private; - -TEST(TimerTest, CategoryTimes) { - Timer::ResetCategoryTimes(); - { - static Timer::Category tcat("CAT1"); - Timer t(tcat, ""); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - StreamString ss; - Timer::DumpCategoryTimes(&ss); - double seconds; - ASSERT_EQ(1, sscanf(ss.GetData(), "%lf sec for CAT1", &seconds)); - EXPECT_LT(0.001, seconds); - EXPECT_GT(0.1, seconds); -} - -TEST(TimerTest, CategoryTimesNested) { - Timer::ResetCategoryTimes(); - { - static Timer::Category tcat1("CAT1"); - Timer t1(tcat1, ""); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - // Explicitly testing the same category as above. - Timer t2(tcat1, ""); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - StreamString ss; - Timer::DumpCategoryTimes(&ss); - double seconds; - // It should only appear once. - ASSERT_EQ(ss.GetString().count("CAT1"), 1U); - ASSERT_EQ(1, sscanf(ss.GetData(), "%lf sec for CAT1", &seconds)); - EXPECT_LT(0.002, seconds); - EXPECT_GT(0.2, seconds); -} - -TEST(TimerTest, CategoryTimes2) { - Timer::ResetCategoryTimes(); - { - static Timer::Category tcat1("CAT1"); - Timer t1(tcat1, ""); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - static Timer::Category tcat2("CAT2"); - Timer t2(tcat2, ""); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - StreamString ss; - Timer::DumpCategoryTimes(&ss); - double seconds1, seconds2; - ASSERT_EQ(2, sscanf(ss.GetData(), "%lf sec for CAT1%*[\n ]%lf sec for CAT2", - &seconds1, &seconds2)) - << "String: " << ss.GetData(); - EXPECT_LT(0.01, seconds1); - EXPECT_GT(1, seconds1); - EXPECT_LT(0.001, seconds2); - EXPECT_GT(0.1, seconds2); -} |