diff options
Diffstat (limited to 'unittests/Core/TimerTest.cpp')
-rw-r--r-- | unittests/Core/TimerTest.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/unittests/Core/TimerTest.cpp b/unittests/Core/TimerTest.cpp index 7e7eeef0a361e..a35df0d49c8e3 100644 --- a/unittests/Core/TimerTest.cpp +++ b/unittests/Core/TimerTest.cpp @@ -18,7 +18,8 @@ using namespace lldb_private; TEST(TimerTest, CategoryTimes) { Timer::ResetCategoryTimes(); { - Timer t("CAT1", ""); + static Timer::Category tcat("CAT1"); + Timer t(tcat, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } StreamString ss; @@ -32,14 +33,18 @@ TEST(TimerTest, CategoryTimes) { TEST(TimerTest, CategoryTimesNested) { Timer::ResetCategoryTimes(); { - Timer t1("CAT1", ""); + static Timer::Category tcat1("CAT1"); + Timer t1(tcat1, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); - Timer t2("CAT1", ""); + // 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); @@ -48,9 +53,11 @@ TEST(TimerTest, CategoryTimesNested) { TEST(TimerTest, CategoryTimes2) { Timer::ResetCategoryTimes(); { - Timer t1("CAT1", ""); + static Timer::Category tcat1("CAT1"); + Timer t1(tcat1, ""); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - Timer t2("CAT2", ""); + static Timer::Category tcat2("CAT2"); + Timer t2(tcat2, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } StreamString ss; |