Add Text benchmark clause for elements without props (#52942)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52942

# Changelog:
[Internal] -

Adds another test clause to the Text benchmark test, to test the case when the component doesn't have any props altogether, which can be useful to establish a baseline.

Reviewed By: rubennorte

Differential Revision: D79352849

fbshipit-source-id: fbfeb53d3ede59631548eb2fe76a4debd5927900
This commit is contained in:
Ruslan Shestopalyuk authored and Facebook GitHub Bot committed 2025-07-31 10:50:31 -07:00
1 parent 626568f9a3
commit 9d6d8a6e65
1 file changed
+55 -28
@@ -17,33 +17,60 @@ 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>
))}
</>
);
Fantom.unstable_benchmark
.suite('Text')
.test.each(
[100, 1000],
n =>
`render ${n.toString()} text component instances with no explicit props`,
() => {
Fantom.runTask(() => root.render(testElements));
},
beforeEach: () => {
root = Fantom.createRoot();
n => ({
beforeAll: () => {
testElements = (
<>
{[...Array(n).keys()].map(i => (
<Text />
))}
</>
);
},
beforeEach: () => {
root = Fantom.createRoot();
},
afterEach: () => {
root.destroy();
},
}),
)
.test.each(
[100, 1000],
n => `render ${n.toString()} text component instances`,
() => {
Fantom.runTask(() => root.render(testElements));
},
afterEach: () => {
root.destroy();
},
}),
);
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();
},
}),
);