From 454f0e805cb43bd8878e73d78e955b9f0af8639d Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 13 Aug 2026 04:18:32 -0700 Subject: [PATCH] Stabilize sampling-profiler tracing test (#57924) Summary: Changelog: [Internal] Exercise JavaScript briefly before ending each trace. This gives the sampling profiler a bounded opportunity to record a stack while preserving the test comparison between disabled and enabled categories. Reviewed By: Abbondanzo Differential Revision: D115740464 --- .../ReactCommon/jsinspector-modern/tests/TracingTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/TracingTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/TracingTest.cpp index c371e76349e6..af45b463e1a4 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/TracingTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/TracingTest.cpp @@ -37,7 +37,15 @@ class TracingTest : public TracingTestBase< TEST_F(TracingTest, EnablesSamplingProfilerOnlyCategoryIsSpecified) { InSequence s; + const auto runSamplingWorkload = [this]() { + eval(R"( + const start = Date.now(); + while (Date.now() - start < 10) {} + )"); + }; + startTracing({}); + runSamplingWorkload(); auto allTraceEvents = endTracingAndCollectEvents(); EXPECT_THAT( @@ -47,6 +55,7 @@ TEST_F(TracingTest, EnablesSamplingProfilerOnlyCategoryIsSpecified) { AtJsonPtr("/cat", "disabled-by-default-v8.cpu_profiler"))))); startTracing({tracing::Category::JavaScriptSampling}); + runSamplingWorkload(); allTraceEvents = endTracingAndCollectEvents(); EXPECT_THAT(