From 9d6d8a6e65c4b26734902fc7f6e8902ed7356803 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Thu, 31 Jul 2025 10:50:31 -0700 Subject: [PATCH] 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 --- .../Text/__tests__/Text-benchmark-itest.js | 83 ++++++++++++------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js b/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js index 5ecfc51a4dc..58d21271417 100644 --- a/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js +++ b/packages/react-native/Libraries/Text/__tests__/Text-benchmark-itest.js @@ -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 instance ${i}`} - ))} - - ); +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 => ( + + ))} + + ); + }, + 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 instance ${i}`} + ))} + + ); + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }), + );