From fee5a570d1ce83db88c92da88634473db6e6e653 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 13 Feb 2025 20:54:12 -0800 Subject: [PATCH] Create fantom benchmarking test to verify impact of props parsing (#49417) Summary: In this diff I'm introducing a fantom benchmarking test to verify impact of props parsing in Fabric (testing for 100, 1000 and 1500 nested views) changelog: [internal] internal Reviewed By: lenaic Differential Revision: D69624243 --- .../View/__tests__/View-benchmark-itest.js | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js b/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js index 4304ab042c94..7d49355a402f 100644 --- a/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js +++ b/packages/react-native/Libraries/Components/View/__tests__/View-benchmark-itest.js @@ -18,6 +18,61 @@ import * as React from 'react'; let root; let thousandViews: React.MixedElement; +function createViewsWithLargeAmountOfPropsAndStyles(count: number): React.Node { + let views: React.Node = null; + for (let i = 0; i < count; i++) { + views = ( + + {views} + + ); + } + return views; +} Fantom.unstable_benchmark .suite('View') @@ -80,4 +135,58 @@ Fantom.unstable_benchmark root.destroy(); }, }, + ) + .test( + 'render 100 views with large amount of props and styles', + () => { + Fantom.runTask(() => root.render(thousandViews)); + }, + { + beforeAll: () => { + // $FlowExpectedError[incompatible-type] + thousandViews = createViewsWithLargeAmountOfPropsAndStyles(100); + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }, + ) + .test( + 'render 1000 views with large amount of props and styles', + () => { + Fantom.runTask(() => root.render(thousandViews)); + }, + { + beforeAll: () => { + // $FlowExpectedError[incompatible-type] + thousandViews = createViewsWithLargeAmountOfPropsAndStyles(1000); + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }, + ) + .test( + 'render 1500 views with large amount of props and styles', + () => { + Fantom.runTask(() => root.render(thousandViews)); + }, + { + beforeAll: () => { + // $FlowExpectedError[incompatible-type] + thousandViews = createViewsWithLargeAmountOfPropsAndStyles(1500); + }, + beforeEach: () => { + root = Fantom.createRoot(); + }, + afterEach: () => { + root.destroy(); + }, + }, );