[llvm] Added instant events to llvm TimeProfiler. (PR #103039)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 03:27:36 PDT 2024


================
@@ -72,4 +72,28 @@ TEST(TimeProfiler, Begin_End_Disabled) {
   timeTraceProfilerEnd();
 }
 
+TEST(TimeProfiler, Instant_Add_Smoke) {
+  setupProfiler();
+
+  timeTraceProfilerBegin("sync event", "sync detail");
+  timeTraceAddInstantEvent("instant event", [&] { return "instant detail"; });
+  timeTraceProfilerEnd();
+
+  std::string json = teardownProfiler();
+  ASSERT_TRUE(json.find(R"("name":"sync event")") != std::string::npos);
+  ASSERT_TRUE(json.find(R"("detail":"sync detail")") != std::string::npos);
+  ASSERT_TRUE(json.find(R"("name":"instant event")") != std::string::npos);
+  ASSERT_TRUE(json.find(R"("detail":"instant detail")") != std::string::npos);
+}
+
+TEST(TimeProfiler, Instant_Not_Added_Smoke) {
+  setupProfiler();
+
+  timeTraceAddInstantEvent("instant event", [&] { return "instant detail"; });
+
+  std::string json = teardownProfiler();
+  ASSERT_FALSE(json.find(R"("name":"instant event")") != std::string::npos);
+  ASSERT_FALSE(json.find(R"("detail":"instant detail")") != std::string::npos);
----------------
ivanaivanovska wrote:

Done.

https://github.com/llvm/llvm-project/pull/103039


More information about the llvm-commits mailing list