mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Create Fantom benchmark test for Text component (#52836)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52836 # Changelog [Internal] - This adds a basic benchmarking test for `Text` component creation, similarly to the one we already have for the e.g. `View`. Reviewed By: rubennorte Differential Revision: D78975332 fbshipit-source-id: e1b54e59a54e8c7f8f19738f2ffeaa02ca5c09ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
012b78c0a5
commit
6d52cf5662
@@ -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
|
||||
id={String(i)}
|
||||
nativeID={String(i)}
|
||||
style={{
|
||||
width: i + 1,
|
||||
height: i + 1,
|
||||
}}>{`Text instance ${i}`}</Text>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
},
|
||||
beforeEach: () => {
|
||||
root = Fantom.createRoot();
|
||||
},
|
||||
afterEach: () => {
|
||||
root.destroy();
|
||||
},
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user