diff --git a/boa/benches/bench_scripts/array_concat.js b/boa/benches/bench_scripts/array_concat.js new file mode 100644 index 00000000000..43bbe106587 --- /dev/null +++ b/boa/benches/bench_scripts/array_concat.js @@ -0,0 +1,6 @@ +(function () { + let arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] + let arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] + + let arr3 = arr1.concat(arr2); +})(); diff --git a/boa/benches/exec.rs b/boa/benches/exec.rs index 99789f4af8f..5e53c6f90e2 100644 --- a/boa/benches/exec.rs +++ b/boa/benches/exec.rs @@ -330,6 +330,16 @@ fn mini_js(c: &mut Criterion) { }); } +static ARRAY_CONCAT: &str = include_str!("bench_scripts/array_concat.js"); + +fn array_concat(c: &mut Criterion) { + let mut context = Context::new(); + let nodes = Parser::new(ARRAY_CONCAT.as_bytes(), false).parse_all().unwrap(); + c.bench_function("Array concat (Execution)", move |b| { + b.iter(|| black_box(&nodes).run(&mut context).unwrap()) + }); +} + criterion_group!( execution, create_realm, @@ -355,5 +365,6 @@ criterion_group!( arithmetic_operations, clean_js, mini_js, + array_concat, ); criterion_main!(execution); diff --git a/boa/benches/full.rs b/boa/benches/full.rs index a46682db38c..b66a650ba6b 100644 --- a/boa/benches/full.rs +++ b/boa/benches/full.rs @@ -196,6 +196,14 @@ fn mini_js(c: &mut Criterion) { }); } +static ARRAY_CONCAT: &str = include_str!("bench_scripts/array_concat.js"); + +fn array_concat(c: &mut Criterion) { + c.bench_function("Array concat (Full)", move |b| { + b.iter(|| Context::new().eval(black_box(ARRAY_CONCAT))) + }); +} + criterion_group!( full, symbol_creation, @@ -220,5 +228,6 @@ criterion_group!( arithmetic_operations, clean_js, mini_js, + array_concat, ); criterion_main!(full); diff --git a/boa/benches/parser.rs b/boa/benches/parser.rs index 464a362bdd0..60889a881fa 100644 --- a/boa/benches/parser.rs +++ b/boa/benches/parser.rs @@ -86,6 +86,14 @@ fn mini_js(c: &mut Criterion) { }); } +static ARRAY_CONCAT: &str = include_str!("bench_scripts/array_concat.js"); + +fn array_concat(c: &mut Criterion) { + c.bench_function("Array concat (Parser)", move |b| { + b.iter(|| Parser::new(black_box(ARRAY_CONCAT.as_bytes()), false).parse_all()) + }); +} + criterion_group!( parser, expression_parser, @@ -95,5 +103,6 @@ criterion_group!( goal_symbol_switch, clean_js, mini_js, + array_concat, ); criterion_main!(parser);