From e774f0d623085d94632f9c600c6280f5ef77eaa2 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 13 Aug 2026 06:59:30 -0700 Subject: [PATCH] Stabilize sampling-profiler tracing test (#57924) Summary: Pull Request resolved: https://github.com/react/react-native/pull/57924 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 fbshipit-source-id: 9aa42ccf597aa9198cb31c2dae601f1709506d24 --- .../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 c371e76349e..af45b463e1a 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(