Skip to content

Commit 454f0e8

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Stabilize sampling-profiler tracing test (react#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
1 parent 4433cdb commit 454f0e8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

packages/react-native/ReactCommon/jsinspector-modern/tests/TracingTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ class TracingTest : public TracingTestBase<
3737
TEST_F(TracingTest, EnablesSamplingProfilerOnlyCategoryIsSpecified) {
3838
InSequence s;
3939

40+
const auto runSamplingWorkload = [this]() {
41+
eval(R"(
42+
const start = Date.now();
43+
while (Date.now() - start < 10) {}
44+
)");
45+
};
46+
4047
startTracing({});
48+
runSamplingWorkload();
4149
auto allTraceEvents = endTracingAndCollectEvents();
4250

4351
EXPECT_THAT(
@@ -47,6 +55,7 @@ TEST_F(TracingTest, EnablesSamplingProfilerOnlyCategoryIsSpecified) {
4755
AtJsonPtr("/cat", "disabled-by-default-v8.cpu_profiler")))));
4856

4957
startTracing({tracing::Category::JavaScriptSampling});
58+
runSamplingWorkload();
5059
allTraceEvents = endTracingAndCollectEvents();
5160

5261
EXPECT_THAT(

0 commit comments

Comments
 (0)