File tree Expand file tree Collapse file tree 7 files changed +362
-974
lines changed
packages/inula2-rust-compiler Expand file tree Collapse file tree 7 files changed +362
-974
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -223,5 +223,55 @@ node quick-benchmark.js --test-case=simple
223223
224224MIT License - 详见 [ LICENSE] ( ../LICENSE ) 文件
225225
226+ # 基准测试与一致性对比
227+
228+ 本目录提供对 openInula 2.0 Rust 编译器的性能基准与(可选)与原版 TS 编译器的输出一致性对比。
229+
230+ ## 先决条件
231+ - Node.js
232+ - 已构建 WASM 包:
233+
234+ ``` bash
235+ npm run build:wasm
236+ ```
237+
238+ ## 仅运行 Rust 基准
239+
240+ ``` bash
241+ node benchmarks/index.js
242+ ```
243+
244+ 不会依赖 TS 基线,直接对 Rust 编译流程(compile_jsx → analyze_reactivity → generate_code)做性能测量。
245+
246+ ## 启用 TS 基线一致性对比(可选)
247+ 通过环境变量指定 TS 编译器命令,脚本会为每个用例生成同一 JSX 的 TS 输出并与 Rust 输出进行归一化对比。
248+
249+ - TS_BASELINE_CMD:TS 编译器的执行命令(需能从 stdin 读取 JSX,stdout 输出结果)
250+ - TS_BASELINE_OPTS:额外参数(可选)
251+ - SAVE_DIFF=1:当存在差异时,将 Rust/TS 输出保存到 ` benchmarks/temp/diffs/ `
252+
253+ 示例:
254+
255+ ``` bash
256+ # 方式一:子模块
257+ # git submodule add <ts-compiler-repo> benchmarks/ts-compiler
258+ # cd benchmarks/ts-compiler && npm i && npm run build
259+ TS_BASELINE_CMD=" node benchmarks/ts-compiler/dist/cli.js" node benchmarks/index.js
260+
261+ # 方式二:使用已发布包
262+ TS_BASELINE_CMD=" npx inula-ts-compiler@<version>" node benchmarks/index.js
263+
264+ # 方式三:使用本地 dist 路径
265+ TS_BASELINE_CMD=" node ../inula-ts-compiler/dist/cli.js" node benchmarks/index.js
266+
267+ # 保存差异输出
268+ SAVE_DIFF=1 TS_BASELINE_CMD=" node benchmarks/ts-compiler/dist/cli.js" node benchmarks/index.js
269+ ```
270+
271+ 当未设置 TS_BASELINE_CMD 时,脚本会打印提示并跳过 TS 基线对比,不会中断基准测试。
272+
273+ ## 结果与报告
274+ 脚本将输出每个场景的耗时与内存统计,并生成 ` benchmarks/report.html ` 简单报告。若启用 ` SAVE_DIFF=1 ` 且发现差异,会在 ` benchmarks/temp/diffs/ ` 下保存对应的 Rust/TS 输出,便于人工核对。
275+
226276
227277
You can’t perform that action at this time.
0 commit comments