diff --git a/packages/react-native-fantom/runner/getFantomTestConfig.js b/packages/react-native-fantom/runner/getFantomTestConfig.js index 660fe4dcd3d7ce..754832e238b44e 100644 --- a/packages/react-native-fantom/runner/getFantomTestConfig.js +++ b/packages/react-native-fantom/runner/getFantomTestConfig.js @@ -47,7 +47,7 @@ const DEFAULT_MODE: FantomTestConfigMode = const FANTOM_FLAG_FORMAT = /^(\w+):(\w+)$/; const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./g; -const FANTOM_BENCHMARK_SUITE_RE = /\nFantom.unstable_benchmark(\s*)\.suite\(/g; +const FANTOM_BENCHMARK_SUITE_RE = /\nFantom\.unstable_benchmark(\s*)\.suite\(/g; /** * Extracts the Fantom configuration from the test file, specified as part of diff --git a/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js b/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js new file mode 100644 index 00000000000000..35b437e3f5de99 --- /dev/null +++ b/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js @@ -0,0 +1,83 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + * @oncall react_native + * @fantom_flags enableAccessToHostTreeInFabric:true + */ + +import '../../../../Libraries/Core/InitializeCore.js'; + +import View from '../View'; +import Fantom from '@react-native/fantom'; +import * as React from 'react'; + +let root; +let thousandViews: React.MixedElement; + +Fantom.unstable_benchmark + .suite('View') + .add( + 'render 100 uncollapsable views', + () => { + Fantom.runTask(() => root.render(thousandViews)); + }, + { + beforeAll: () => { + let views: React.Node = null; + for (let i = 0; i < 100; i++) { + views = ( + + {views} + + ); + } + // $FlowExpectedError[incompatible-type] + thousandViews = views; + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }, + ) + .add( + 'render 1000 uncollapsable views', + () => { + Fantom.runTask(() => root.render(thousandViews)); + }, + { + beforeAll: () => { + let views: React.Node = null; + for (let i = 0; i < 1000; i++) { + views = ( + + {views} + + ); + } + // $FlowExpectedError[incompatible-type] + thousandViews = views; + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }, + );