Skip to content

Commit 9d6d8a6

Browse files
rshestfacebook-github-bot
authored andcommitted
Add Text benchmark clause for elements without props (#52942)
Summary: Pull Request resolved: #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
1 parent 626568f commit 9d6d8a6

1 file changed

Lines changed: 55 additions & 28 deletions

File tree

packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,60 @@ import {Text} from 'react-native';
1717
let root;
1818
let testElements: React.MixedElement;
1919

20-
Fantom.unstable_benchmark.suite('Text').test.each(
21-
[100, 1000],
22-
n => `render ${n.toString()} text component instances`,
23-
() => {
24-
Fantom.runTask(() => root.render(testElements));
25-
},
26-
n => ({
27-
beforeAll: () => {
28-
testElements = (
29-
<>
30-
{[...Array(n).keys()].map(i => (
31-
<Text
32-
id={String(i)}
33-
nativeID={String(i)}
34-
style={{
35-
width: i + 1,
36-
height: i + 1,
37-
}}>{`Text instance ${i}`}</Text>
38-
))}
39-
</>
40-
);
20+
Fantom.unstable_benchmark
21+
.suite('Text')
22+
.test.each(
23+
[100, 1000],
24+
n =>
25+
`render ${n.toString()} text component instances with no explicit props`,
26+
() => {
27+
Fantom.runTask(() => root.render(testElements));
4128
},
42-
beforeEach: () => {
43-
root = Fantom.createRoot();
29+
n => ({
30+
beforeAll: () => {
31+
testElements = (
32+
<>
33+
{[...Array(n).keys()].map(i => (
34+
<Text />
35+
))}
36+
</>
37+
);
38+
},
39+
beforeEach: () => {
40+
root = Fantom.createRoot();
41+
},
42+
afterEach: () => {
43+
root.destroy();
44+
},
45+
}),
46+
)
47+
.test.each(
48+
[100, 1000],
49+
n => `render ${n.toString()} text component instances`,
50+
() => {
51+
Fantom.runTask(() => root.render(testElements));
4452
},
45-
afterEach: () => {
46-
root.destroy();
47-
},
48-
}),
49-
);
53+
n => ({
54+
beforeAll: () => {
55+
testElements = (
56+
<>
57+
{[...Array(n).keys()].map(i => (
58+
<Text
59+
id={String(i)}
60+
nativeID={String(i)}
61+
style={{
62+
width: i + 1,
63+
height: i + 1,
64+
}}>{`Text instance ${i}`}</Text>
65+
))}
66+
</>
67+
);
68+
},
69+
beforeEach: () => {
70+
root = Fantom.createRoot();
71+
},
72+
afterEach: () => {
73+
root.destroy();
74+
},
75+
}),
76+
);

0 commit comments

Comments
 (0)