diff --git a/.changeset/calm-zebras-smile.md b/.changeset/calm-zebras-smile.md new file mode 100644 index 0000000000..853d812bb3 --- /dev/null +++ b/.changeset/calm-zebras-smile.md @@ -0,0 +1,3 @@ +--- + +--- diff --git a/benchmark/react/cases/008-many-use-state/index.tsx b/benchmark/react/cases/008-many-use-state/index.tsx new file mode 100644 index 0000000000..2e7540ddb7 --- /dev/null +++ b/benchmark/react/cases/008-many-use-state/index.tsx @@ -0,0 +1,32 @@ +// Copyright 2026 The Lynx Authors. All rights reserved. +// Licensed under the Apache License Version 2.0 that can be found in the +// LICENSE file in the root directory of this source tree. + +import { root, useState } from '@lynx-js/react'; + +import { RunBenchmarkUntilHydrate } from '../../src/RunBenchmarkUntil.js'; + +function Item() { + const [counter] = useState(0); + return counter === 1 ? {counter} : null; +} +function App() { + return ( + + {Array.from({ + length: 1000, + }).map(() => { + return ; + })} + + ); +} + +runAfterLoadScript(() => { + root.render( + <> + + + , + ); +}); diff --git a/benchmark/react/lynx.config.js b/benchmark/react/lynx.config.js index 64eecb0854..2e1e1da683 100644 --- a/benchmark/react/lynx.config.js +++ b/benchmark/react/lynx.config.js @@ -53,6 +53,10 @@ export default defineConfig({ './src/patchProfile.ts', './cases/007-four-layer-views/index.tsx', ], + '008-many-use-state': [ + './src/patchProfile.ts', + './cases/008-many-use-state/index.tsx', + ], }, }, plugins: [ diff --git a/benchmark/react/package.json b/benchmark/react/package.json index 78233f1ac0..414884ffa4 100644 --- a/benchmark/react/package.json +++ b/benchmark/react/package.json @@ -12,6 +12,7 @@ "bench:005-load-script": "benchx_cli run dist/005-load-script.lynx.bundle", "bench:006-static-raw-text": "benchx_cli run dist/006-static-raw-text.lynx.bundle --wait-for-id=stop-benchmark-true", "bench:007-four-layer-views": "benchx_cli run dist/007-four-layer-views.lynx.bundle --wait-for-id=stop-benchmark-true", + "bench:008-many-use-state": "benchx_cli run dist/008-many-use-state.lynx.bundle --wait-for-id=stop-benchmark-true", "build": "rspeedy build", "dev": "rspeedy dev", "perfetto": "pnpm run --sequential --stream --aggregate-output '/^perfetto:.*/'", @@ -22,6 +23,7 @@ "perfetto:005-load-script": "benchx_cli -o dist/005-load-script.ptrace run dist/005-load-script.lynx.bundle", "perfetto:006-static-raw-text": "benchx_cli -o dist/006-static-raw-text.ptrace run dist/006-static-raw-text.lynx.bundle --wait-for-id=stop-benchmark-true", "perfetto:007-four-layer-views": "benchx_cli -o dist/007-four-layer-views.ptrace run dist/007-four-layer-views.lynx.bundle --wait-for-id=stop-benchmark-true", + "perfetto:008-many-use-state": "benchx_cli -o dist/008-many-use-state.ptrace run dist/008-many-use-state.lynx.bundle --wait-for-id=stop-benchmark-true", "test": "npm run perfetto && node scripts/detectLeak.mjs" }, "dependencies": {