diff --git a/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js b/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js new file mode 100644 index 00000000000..5ecfc51a4dc --- /dev/null +++ b/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js @@ -0,0 +1,49 @@ +/** + * 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 + */ + +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; + +import * as Fantom from '@react-native/fantom'; +import * as React from 'react'; +import {Text} from 'react-native'; + +let root; +let testElements: React.MixedElement; + +Fantom.unstable_benchmark.suite('Text').test.each( + [100, 1000], + n => `render ${n.toString()} text component instances`, + () => { + Fantom.runTask(() => root.render(testElements)); + }, + n => ({ + beforeAll: () => { + testElements = ( + <> + {[...Array(n).keys()].map(i => ( + {`Text instance ${i}`} + ))} + + ); + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }), +);