Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions benchmark/react/cases/006-fuzz-complex-1000/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2025 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, useEffect, useState } from '@lynx-js/react';
import { process } from '@lynx-js/react/internal';

import { genRandom, genValue } from '../../plugins/gen.js';

const F = __GENERATE_JSX__(0, 1000)({ useState }, genRandom, genValue);

function App() {
const [stopBenchmark, setStopBenchmark] = useState(false);
const [seed, setSeed] = useState(100);
useEffect(() => {
setTimeout(() => {
setSeed(101);
setStopBenchmark(true);
Codspeed.startBenchmark();
process();
Codspeed.stopBenchmark();
Codspeed.setExecutedBenchmark(
`${__REPO_FILEPATH__}::${__webpack_chunkname__}-preactProcess`,
);
}, 0);
}, []);
return (
<>
<F seed={seed} />
<view id={`stop-benchmark-${stopBenchmark}`} />
</>
);
}

runAfterLoadScript(() => {
root.render(
<App />,
);
});
Comment on lines +35 to +39
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Globals typing coverage

Ensure rspeedy-env.d.ts declares runAfterLoadScript, Codspeed, REPO_FILEPATH, and webpack_chunkname so TS stays clean without local ignores.


🏁 Script executed:

#!/bin/bash
# Check ambient declarations for globals/macros
rg -nP -C1 'declare\s+(var|const|function)\s+(runAfterLoadScript|Codspeed|__REPO_FILEPATH__|__webpack_chunkname__)' benchmark/react/rspeedy-env.d.ts

Length of output: 215


Add ambient declaration for webpack_chunkname in benchmark/react/rspeedy-env.d.ts

rspeedy-env.d.ts already declares Codspeed, runAfterLoadScript, and REPO_FILEPATH; add the missing ambient declaration:

declare const webpack_chunkname: string;

🤖 Prompt for AI Agents
In benchmark/react/cases/006-fuzz-complex-1000/index.tsx around lines 37 to 41,
the environment declaration file rspeedy-env.d.ts is missing an ambient
declaration for __webpack_chunkname__, causing TypeScript to error when that
global is used; add the line declare const __webpack_chunkname__: string; to
rspeedy-env.d.ts alongside the existing declarations (Codspeed,
runAfterLoadScript, __REPO_FILEPATH__) so the global is recognized by the
compiler.

39 changes: 39 additions & 0 deletions benchmark/react/cases/006-fuzz-complex-2000/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2025 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, useEffect, useState } from '@lynx-js/react';
import { process } from '@lynx-js/react/internal';

import { genRandom, genValue } from '../../plugins/gen.js';

const F = __GENERATE_JSX__(0, 2000)({ useState }, genRandom, genValue);

function App() {
const [stopBenchmark, setStopBenchmark] = useState(false);
const [seed, setSeed] = useState(100);
useEffect(() => {
setTimeout(() => {
setSeed(101);
setStopBenchmark(true);
Codspeed.startBenchmark();
process();
Codspeed.stopBenchmark();
Codspeed.setExecutedBenchmark(
`${__REPO_FILEPATH__}::${__webpack_chunkname__}-preactProcess`,
);
}, 0);
}, []);
Comment thread
hzy marked this conversation as resolved.
return (
<>
<F seed={seed} />
<view id={`stop-benchmark-${stopBenchmark}`} />
</>
);
}

runAfterLoadScript(() => {
root.render(
<App />,
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin';
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
import { defineConfig } from '@lynx-js/rspeedy';

import { pluginGenJSX } from './plugins/pluginGenJSX.mjs';
import { pluginRepoFilePath } from './plugins/pluginRepoFilePath.mjs';
import { pluginScriptLoad } from './plugins/pluginScriptLoad.mjs';

Expand Down Expand Up @@ -45,9 +46,18 @@ export default defineConfig({
'005-load-script': [
'./cases/005-load-script/index.tsx',
],
'006-fuzz-complex-1000': [
'./src/patchProfile.ts',
'./cases/006-fuzz-complex-1000/index.tsx',
],
'006-fuzz-complex-2000': [
'./src/patchProfile.ts',
'./cases/006-fuzz-complex-2000/index.tsx',
],
},
},
plugins: [
pluginGenJSX(),
pluginRepoFilePath(),
pluginReactLynx({
enableParallelElement: false,
Expand Down
7 changes: 6 additions & 1 deletion benchmark/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"bench:003-hello-list": "benchx_cli run dist/003-hello-list.lynx.bundle --wait-for-id=stop-benchmark-true",
"bench:004-various-update": "benchx_cli run dist/004-various-update.lynx.bundle --wait-for-id=stop-benchmark-true",
"bench:005-load-script": "benchx_cli run dist/005-load-script.lynx.bundle",
"bench:006-fuzz-complex-1000": "benchx_cli run dist/006-fuzz-complex-1000.lynx.bundle --wait-for-id=stop-benchmark-true",
"bench:006-fuzz-complex-2000": "benchx_cli run dist/006-fuzz-complex-2000.lynx.bundle --wait-for-id=stop-benchmark-true",
"build": "rspeedy build",
"dev": "rspeedy dev",
"perfetto": "pnpm run --sequential --stream --aggregate-output '/^perfetto:.*/'",
Expand All @@ -18,6 +20,8 @@
"perfetto:003-hello-list": "benchx_cli -o dist/003-hello-list.ptrace run dist/003-hello-list.lynx.bundle --wait-for-id=stop-benchmark-true",
"perfetto:004-various-update": "benchx_cli -o dist/004-various-update.ptrace run dist/004-various-update.lynx.bundle --wait-for-id=stop-benchmark-true",
"perfetto:005-load-script": "benchx_cli -o dist/005-load-script.ptrace run dist/005-load-script.lynx.bundle",
"perfetto:006-fuzz-complex-1000": "benchx_cli -o dist/006-fuzz-complex-1000.ptrace run dist/006-fuzz-complex-1000.lynx.bundle --wait-for-id=stop-benchmark-true",
"perfetto:006-fuzz-complex-2000": "benchx_cli -o dist/006-fuzz-complex-2000.ptrace run dist/006-fuzz-complex-2000.lynx.bundle --wait-for-id=stop-benchmark-true",
"test": "echo 'No tests specified'"
},
"dependencies": {
Expand All @@ -34,6 +38,7 @@
"@lynx-js/rspeedy": "workspace:*",
"@lynx-js/type-element-api": "0.0.2",
"@lynx-js/types": "3.4.11",
"@types/react": "^18.3.23"
"@types/react": "^18.3.23",
"human-id": "4.1.1"
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Loading
Loading