mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
fix: Compiler 改带字段 struct 后 5 处 bench 用 new() 构造
04-03 将 Compiler 从 unit struct 改为带 enable_dce 字段后, bench 里旧语法 'Compiler.compile(...)' 编译失败(clippy --all-targets 暴露,cargo test 不编 bench)。统一改 Compiler::new().compile(...)。
This commit is contained in:
@@ -9,7 +9,7 @@ fn bench_call(c: &mut Criterion) {
|
||||
let js = "function fib(n) { if (n < 2) return n; return fib(n-1) + fib(n-2); } fib(15);";
|
||||
let alloc = oxide_parser::Allocator::default();
|
||||
let program = oxide_parser::parse(&alloc, js).expect("parse");
|
||||
let module = Compiler.compile(&program).expect("compile");
|
||||
let module = Compiler::new().compile(&program).expect("compile");
|
||||
|
||||
c.bench_function("call", |b| {
|
||||
b.iter_batched(
|
||||
|
||||
@@ -9,7 +9,7 @@ fn bench_coercion(c: &mut Criterion) {
|
||||
let js = "var x = \"42\"; var y = \"3.14\"; var r = 0; for (var i = 0; i < 5000; i++) { r += (+x) + (+y); } r";
|
||||
let alloc = oxide_parser::Allocator::default();
|
||||
let program = oxide_parser::parse(&alloc, js).expect("parse");
|
||||
let module = Compiler.compile(&program).expect("compile");
|
||||
let module = Compiler::new().compile(&program).expect("compile");
|
||||
|
||||
c.bench_function("coercion", |b| {
|
||||
b.iter_batched(
|
||||
|
||||
@@ -9,7 +9,7 @@ fn bench_dispatch(c: &mut Criterion) {
|
||||
let js = "var x = 0; for (var i = 0; i < 10000; i++) { x = x + i - i * 2 + (i % 3); } x";
|
||||
let alloc = oxide_parser::Allocator::default();
|
||||
let program = oxide_parser::parse(&alloc, js).expect("parse");
|
||||
let module = Compiler.compile(&program).expect("compile");
|
||||
let module = Compiler::new().compile(&program).expect("compile");
|
||||
|
||||
c.bench_function("dispatch", |b| {
|
||||
b.iter_batched(
|
||||
|
||||
@@ -11,7 +11,7 @@ fn bench_gc(c: &mut Criterion) {
|
||||
let js = "var g = {}; for (var i = 0; i < 500; i++) { var obj = { x: i, y: i * 2 }; g[i] = obj; } g[\"x\"]";
|
||||
let alloc = oxide_parser::Allocator::default();
|
||||
let program = oxide_parser::parse(&alloc, js).expect("parse");
|
||||
let module = Compiler.compile(&program).expect("compile");
|
||||
let module = Compiler::new().compile(&program).expect("compile");
|
||||
|
||||
c.bench_function("gc_mark_sweep", |b| {
|
||||
b.iter_batched(
|
||||
|
||||
@@ -9,7 +9,7 @@ fn bench_property(c: &mut Criterion) {
|
||||
let js = "var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 }; var sum = 0; for (var i = 0; i < 10000; i++) { sum += obj.a + obj.b + obj.c + obj.d + obj.e; } sum";
|
||||
let alloc = oxide_parser::Allocator::default();
|
||||
let program = oxide_parser::parse(&alloc, js).expect("parse");
|
||||
let module = Compiler.compile(&program).expect("compile");
|
||||
let module = Compiler::new().compile(&program).expect("compile");
|
||||
|
||||
c.bench_function("property", |b| {
|
||||
b.iter_batched(
|
||||
|
||||
Reference in New Issue
Block a user