Browse Source

Benchmark refactor (#640)

pull/650/head
neeldug 4 years ago committed by GitHub
parent
commit
bbacf1d095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      boa/benches/bench_scripts/arithmetic_operations.js
  2. 7
      boa/benches/bench_scripts/array_access.js
  3. 8
      boa/benches/bench_scripts/array_create.js
  4. 24
      boa/benches/bench_scripts/array_pop.js
  5. 7
      boa/benches/bench_scripts/boolean_object_access.js
  6. 1
      boa/benches/bench_scripts/expression.js
  7. 10
      boa/benches/bench_scripts/fibonacci.js
  8. 10
      boa/benches/bench_scripts/for_loop.js
  9. 7
      boa/benches/bench_scripts/goal_symbol_switch.js
  10. 1
      boa/benches/bench_scripts/hello_world.js
  11. 9
      boa/benches/bench_scripts/long_repetition.js
  12. 7
      boa/benches/bench_scripts/number_object_access.js
  13. 8
      boa/benches/bench_scripts/object_creation.js
  14. 8
      boa/benches/bench_scripts/object_prop_access_const.js
  15. 8
      boa/benches/bench_scripts/object_prop_access_dyn.js
  16. 5
      boa/benches/bench_scripts/regexp.js
  17. 5
      boa/benches/bench_scripts/regexp_creation.js
  18. 5
      boa/benches/bench_scripts/regexp_literal.js
  19. 5
      boa/benches/bench_scripts/regexp_literal_creation.js
  20. 9
      boa/benches/bench_scripts/string_compare.js
  21. 6
      boa/benches/bench_scripts/string_concat.js
  22. 4
      boa/benches/bench_scripts/string_copy.js
  23. 7
      boa/benches/bench_scripts/string_object_access.js
  24. 3
      boa/benches/bench_scripts/symbol_creation.js
  25. 209
      boa/benches/exec.rs
  26. 207
      boa/benches/full.rs
  27. 18
      boa/benches/lexer.rs
  28. 40
      boa/benches/parser.rs

1
boa/benches/bench_scripts/arithmetic_operations.js

@ -0,0 +1 @@
((2 + 2) ** 3 / 100 - 5 ** 3 * -1000) ** 2 + 100 - 8

7
boa/benches/bench_scripts/array_access.js

@ -0,0 +1,7 @@
(function () {
let testArr = [1,2,3,4,5];
let res = testArr[2];
return res;
})();

8
boa/benches/bench_scripts/array_create.js

@ -0,0 +1,8 @@
(function(){
let testArr = [];
for (let a = 0; a <= 500; a++) {
testArr[a] = ('p' + a);
}
return testArr;
})();

24
boa/benches/bench_scripts/array_pop.js

@ -0,0 +1,24 @@
(function(){
let testArray = [83, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828,
234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62,
99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67,
77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29,
2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28,
83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32,
56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93,
27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93,
17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23,
56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36,
28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234,
23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99,
36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28];
while (testArray.length > 0) {
testArray.pop();
}
return testArray;
})();

7
boa/benches/bench_scripts/boolean_object_access.js

@ -0,0 +1,7 @@
new Boolean(
!new Boolean(
new Boolean(
!(new Boolean(false).valueOf()) && (new Boolean(true).valueOf())
).valueOf()
).valueOf()
).valueOf()

1
boa/benches/bench_scripts/expression.js

@ -0,0 +1 @@
1 + 1 + 1 + 1 + 1 + 1 / 1 + 1 + 1 * 1 + 1 + 1 + 1;

10
boa/benches/bench_scripts/fibonacci.js

@ -0,0 +1,10 @@
(function () {
let num = 12;
function fib(n) {
if (n <= 1) return 1;
return fib(n - 1) + fib(n - 2);
}
return fib(num);
})();

10
boa/benches/bench_scripts/for_loop.js

@ -0,0 +1,10 @@
(function () {
let b = "hello";
for (let a = 10; a < 100; a += 5) {
if (a < 50) {
b += "world";
}
}
return b;
})();

7
boa/benches/bench_scripts/goal_symbol_switch.js

@ -0,0 +1,7 @@
function foo(regex, num) {}
let i = 0;
while (i < 1000000) {
foo(/ab+c/, 5.0/5);
i++;
}

1
boa/benches/bench_scripts/hello_world.js

@ -0,0 +1 @@
let foo = 'hello world!'; foo;

9
boa/benches/bench_scripts/long_repetition.js

@ -0,0 +1,9 @@
for (let a = 10; a < 100; a++) {
if (a < 10) {
console.log("impossible D:");
} else if (a < 50) {
console.log("starting");
} else {
console.log("finishing");
}
}

7
boa/benches/bench_scripts/number_object_access.js

@ -0,0 +1,7 @@
new Number(
new Number(
new Number(
new Number(100).valueOf() - 10.5
).valueOf() + 100
).valueOf() * 1.6
)

8
boa/benches/bench_scripts/object_creation.js

@ -0,0 +1,8 @@
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test;
})();

8
boa/benches/bench_scripts/object_prop_access_const.js

@ -0,0 +1,8 @@
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test.my_prop;
})();

8
boa/benches/bench_scripts/object_prop_access_dyn.js

@ -0,0 +1,8 @@
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test["my" + "_prop"];
})();

5
boa/benches/bench_scripts/regexp.js

@ -0,0 +1,5 @@
(function () {
let regExp = new RegExp('hello', 'i');
return regExp.test("Hello World");
})();

5
boa/benches/bench_scripts/regexp_creation.js

@ -0,0 +1,5 @@
(function () {
let regExp = new RegExp('hello', 'i');
return regExp;
})();

5
boa/benches/bench_scripts/regexp_literal.js

@ -0,0 +1,5 @@
(function () {
let regExp = /hello/i;
return regExp.test("Hello World");
})();

5
boa/benches/bench_scripts/regexp_literal_creation.js

@ -0,0 +1,5 @@
(function () {
let regExp = /hello/i;
return regExp;
})();

9
boa/benches/bench_scripts/string_compare.js

@ -0,0 +1,9 @@
(function(){
var a = "hello";
var b = "world";
var c = a == b;
var d = b;
var e = d == b;
})();

6
boa/benches/bench_scripts/string_concat.js

@ -0,0 +1,6 @@
(function(){
var a = "hello";
var b = "world";
var c = a + b;
})();

4
boa/benches/bench_scripts/string_copy.js

@ -0,0 +1,4 @@
(function(){
var a = "hello";
var b = a;
})();

7
boa/benches/bench_scripts/string_object_access.js

@ -0,0 +1,7 @@
new String(
new String(
new String(
new String('Hello').valueOf() + new String(", world").valueOf()
).valueOf() + '!'
).valueOf()
).valueOf()

3
boa/benches/bench_scripts/symbol_creation.js

@ -0,0 +1,3 @@
(function () {
return Symbol();
})();

209
boa/benches/exec.rs

@ -10,16 +10,12 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
static SYMBOL_CREATION: &str = r#"
(function () {
return Symbol();
})();
"#;
fn create_realm(c: &mut Criterion) {
c.bench_function("Create Realm", move |b| b.iter(Realm::create));
}
static SYMBOL_CREATION: &str = include_str!("bench_scripts/symbol_creation.js");
fn symbol_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
@ -38,18 +34,7 @@ fn symbol_creation(c: &mut Criterion) {
});
}
static FOR_LOOP: &str = r#"
(function () {
let b = "hello";
for (let a = 10; a < 100; a += 5) {
if (a < 50) {
b += "world";
}
}
return b;
})();
"#;
static FOR_LOOP: &str = include_str!("bench_scripts/for_loop.js");
fn for_loop_execution(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -69,18 +54,7 @@ fn for_loop_execution(c: &mut Criterion) {
});
}
static FIBONACCI: &str = r#"
(function () {
let num = 12;
function fib(n) {
if (n <= 1) return 1;
return fib(n - 1) + fib(n - 2);
}
return fib(num);
})();
"#;
static FIBONACCI: &str = include_str!("bench_scripts/fibonacci.js");
fn fibonacci(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -100,16 +74,7 @@ fn fibonacci(c: &mut Criterion) {
});
}
static OBJECT_CREATION: &str = r#"
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test;
})();
"#;
static OBJECT_CREATION: &str = include_str!("bench_scripts/object_creation.js");
fn object_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -129,16 +94,7 @@ fn object_creation(c: &mut Criterion) {
});
}
static OBJECT_PROP_ACCESS_CONST: &str = r#"
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test.my_prop;
})();
"#;
static OBJECT_PROP_ACCESS_CONST: &str = include_str!("bench_scripts/object_prop_access_const.js");
fn object_prop_access_const(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -158,16 +114,7 @@ fn object_prop_access_const(c: &mut Criterion) {
});
}
static OBJECT_PROP_ACCESS_DYN: &str = r#"
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test["my" + "_prop"];
})();
"#;
static OBJECT_PROP_ACCESS_DYN: &str = include_str!("bench_scripts/object_prop_access_dyn.js");
fn object_prop_access_dyn(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -187,13 +134,7 @@ fn object_prop_access_dyn(c: &mut Criterion) {
});
}
static REGEXP_LITERAL_CREATION: &str = r#"
(function () {
let regExp = /hello/i;
return regExp;
})();
"#;
static REGEXP_LITERAL_CREATION: &str = include_str!("bench_scripts/regexp_literal_creation.js");
fn regexp_literal_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -213,13 +154,7 @@ fn regexp_literal_creation(c: &mut Criterion) {
});
}
static REGEXP_CREATION: &str = r#"
(function () {
let regExp = new RegExp('hello', 'i');
return regExp;
})();
"#;
static REGEXP_CREATION: &str = include_str!("bench_scripts/regexp_creation.js");
fn regexp_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -239,13 +174,7 @@ fn regexp_creation(c: &mut Criterion) {
});
}
static REGEXP_LITERAL: &str = r#"
(function () {
let regExp = /hello/i;
return regExp.test("Hello World");
})();
"#;
static REGEXP_LITERAL: &str = include_str!("bench_scripts/regexp_literal.js");
fn regexp_literal(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -265,13 +194,7 @@ fn regexp_literal(c: &mut Criterion) {
});
}
static REGEXP: &str = r#"
(function () {
let regExp = new RegExp('hello', 'i');
return regExp.test("Hello World");
})();
"#;
static REGEXP: &str = include_str!("bench_scripts/regexp.js");
fn regexp(c: &mut Criterion) {
// Create new Realm and interpreter.
@ -291,15 +214,7 @@ fn regexp(c: &mut Criterion) {
});
}
static ARRAY_ACCESS: &str = r#"
(function () {
let testArr = [1,2,3,4,5];
let res = testArr[2];
return res;
})();
"#;
static ARRAY_ACCESS: &str = include_str!("bench_scripts/array_access.js");
fn array_access(c: &mut Criterion) {
let realm = Realm::create();
@ -315,16 +230,7 @@ fn array_access(c: &mut Criterion) {
});
}
static ARRAY_CREATE: &str = r#"
(function(){
let testArr = [];
for (let a = 0; a <= 500; a++) {
testArr[a] = ('p' + a);
}
return testArr;
})();
"#;
static ARRAY_CREATE: &str = include_str!("bench_scripts/array_create.js");
fn array_creation(c: &mut Criterion) {
let realm = Realm::create();
@ -340,32 +246,7 @@ fn array_creation(c: &mut Criterion) {
});
}
static ARRAY_POP: &str = r#"
(function(){
let testArray = [83, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828,
234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62,
99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67,
77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29,
2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28,
83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32,
56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93,
27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93,
17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23,
56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36,
28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234,
23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99,
36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28];
while (testArray.length > 0) {
testArray.pop();
}
return testArray;
})();
"#;
static ARRAY_POP: &str = include_str!("bench_scripts/array_pop.js");
fn array_pop(c: &mut Criterion) {
let realm = Realm::create();
@ -381,14 +262,7 @@ fn array_pop(c: &mut Criterion) {
});
}
static STRING_CONCAT: &str = r#"
(function(){
var a = "hello";
var b = "world";
var c = a + b;
})();
"#;
static STRING_CONCAT: &str = include_str!("bench_scripts/string_concat.js");
fn string_concat(c: &mut Criterion) {
let realm = Realm::create();
@ -404,17 +278,7 @@ fn string_concat(c: &mut Criterion) {
});
}
static STRING_COMPARE: &str = r#"
(function(){
var a = "hello";
var b = "world";
var c = a == b;
var d = b;
var e = d == b;
})();
"#;
static STRING_COMPARE: &str = include_str!("bench_scripts/string_compare.js");
fn string_compare(c: &mut Criterion) {
let realm = Realm::create();
@ -430,12 +294,7 @@ fn string_compare(c: &mut Criterion) {
});
}
static STRING_COPY: &str = r#"
(function(){
var a = "hello";
var b = a;
})();
"#;
static STRING_COPY: &str = include_str!("bench_scripts/string_copy.js");
fn string_copy(c: &mut Criterion) {
let realm = Realm::create();
@ -451,15 +310,7 @@ fn string_copy(c: &mut Criterion) {
});
}
static NUMBER_OBJECT_ACCESS: &str = r#"
new Number(
new Number(
new Number(
new Number(100).valueOf() - 10.5
).valueOf() + 100
).valueOf() * 1.6
)
"#;
static NUMBER_OBJECT_ACCESS: &str = include_str!("bench_scripts/number_object_access.js");
fn number_object_access(c: &mut Criterion) {
let realm = Realm::create();
@ -475,15 +326,7 @@ fn number_object_access(c: &mut Criterion) {
});
}
static BOOLEAN_OBJECT_ACCESS: &str = r#"
new Boolean(
!new Boolean(
new Boolean(
!(new Boolean(false).valueOf()) && (new Boolean(true).valueOf())
).valueOf()
).valueOf()
).valueOf()
"#;
static BOOLEAN_OBJECT_ACCESS: &str = include_str!("bench_scripts/boolean_object_access.js");
fn boolean_object_access(c: &mut Criterion) {
let realm = Realm::create();
@ -499,15 +342,7 @@ fn boolean_object_access(c: &mut Criterion) {
});
}
static STRING_OBJECT_ACCESS: &str = r#"
new String(
new String(
new String(
new String('Hello').valueOf() + new String(", world").valueOf()
).valueOf() + '!'
).valueOf()
).valueOf()
"#;
static STRING_OBJECT_ACCESS: &str = include_str!("bench_scripts/string_object_access.js");
fn string_object_access(c: &mut Criterion) {
let realm = Realm::create();
@ -523,9 +358,7 @@ fn string_object_access(c: &mut Criterion) {
});
}
static ARITHMETIC_OPERATIONS: &str = r#"
((2 + 2) ** 3 / 100 - 5 ** 3 * -1000) ** 2 + 100 - 8
"#;
static ARITHMETIC_OPERATIONS: &str = include_str!("bench_scripts/arithmetic_operations.js");
fn arithmetic_operations(c: &mut Criterion) {
let realm = Realm::create();

207
boa/benches/full.rs

@ -10,11 +10,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
static SYMBOL_CREATION: &str = r#"
(function () {
return Symbol();
})();
"#;
static SYMBOL_CREATION: &str = include_str!("bench_scripts/symbol_creation.js");
fn symbol_creation(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -23,18 +19,7 @@ fn symbol_creation(c: &mut Criterion) {
});
}
static FOR_LOOP: &str = r#"
(function () {
let b = "hello";
for (let a = 10; a < 100; a += 5) {
if (a < 50) {
b += "world";
}
}
return b;
})();
"#;
static FOR_LOOP: &str = include_str!("bench_scripts/for_loop.js");
fn for_loop(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -43,18 +28,7 @@ fn for_loop(c: &mut Criterion) {
});
}
static FIBONACCI: &str = r#"
(function () {
let num = 12;
function fib(n) {
if (n <= 1) return 1;
return fib(n - 1) + fib(n - 2);
}
return fib(num);
})();
"#;
static FIBONACCI: &str = include_str!("bench_scripts/fibonacci.js");
fn fibonacci(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -63,16 +37,7 @@ fn fibonacci(c: &mut Criterion) {
});
}
static OBJECT_CREATION: &str = r#"
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test;
})();
"#;
static OBJECT_CREATION: &str = include_str!("bench_scripts/object_creation.js");
fn object_creation(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -81,16 +46,7 @@ fn object_creation(c: &mut Criterion) {
});
}
static OBJECT_PROP_ACCESS_CONST: &str = r#"
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test.my_prop;
})();
"#;
static OBJECT_PROP_ACCESS_CONST: &str = include_str!("bench_scripts/object_prop_access_const.js");
fn object_prop_access_const(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -99,16 +55,7 @@ fn object_prop_access_const(c: &mut Criterion) {
});
}
static OBJECT_PROP_ACCESS_DYN: &str = r#"
(function () {
let test = {
my_prop: "hello",
another: 65,
};
return test["my" + "_prop"];
})();
"#;
static OBJECT_PROP_ACCESS_DYN: &str = include_str!("bench_scripts/object_prop_access_dyn.js");
fn object_prop_access_dyn(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -117,13 +64,7 @@ fn object_prop_access_dyn(c: &mut Criterion) {
});
}
static REGEXP_LITERAL_CREATION: &str = r#"
(function () {
let regExp = /hello/i;
return regExp;
})();
"#;
static REGEXP_LITERAL_CREATION: &str = include_str!("bench_scripts/regexp_literal_creation.js");
fn regexp_literal_creation(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -132,13 +73,7 @@ fn regexp_literal_creation(c: &mut Criterion) {
});
}
static REGEXP_CREATION: &str = r#"
(function () {
let regExp = new RegExp('hello', 'i');
return regExp;
})();
"#;
static REGEXP_CREATION: &str = include_str!("bench_scripts/regexp_creation.js");
fn regexp_creation(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -147,13 +82,7 @@ fn regexp_creation(c: &mut Criterion) {
});
}
static REGEXP_LITERAL: &str = r#"
(function () {
let regExp = /hello/i;
return regExp.test("Hello World");
})();
"#;
static REGEXP_LITERAL: &str = include_str!("bench_scripts/regexp_literal.js");
fn regexp_literal(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
@ -162,28 +91,14 @@ fn regexp_literal(c: &mut Criterion) {
});
}
static REGEXP: &str = r#"
(function () {
let regExp = new RegExp('hello', 'i');
return regExp.test("Hello World");
})();
"#;
static REGEXP: &str = include_str!("bench_scripts/regexp.js");
fn regexp(c: &mut Criterion) {
// Execute the code by taking into account realm creation, lexing and parsing
c.bench_function("RegExp (Full)", move |b| b.iter(|| exec(black_box(REGEXP))));
}
static ARRAY_ACCESS: &str = r#"
(function () {
let testArr = [1,2,3,4,5];
let res = testArr[2];
return res;
})();
"#;
static ARRAY_ACCESS: &str = include_str!("bench_scripts/array_access.js");
fn array_access(c: &mut Criterion) {
c.bench_function("Array access (Full)", move |b| {
@ -191,16 +106,7 @@ fn array_access(c: &mut Criterion) {
});
}
static ARRAY_CREATE: &str = r#"
(function(){
let testArr = [];
for (let a = 0; a <= 500; a++) {
testArr[a] = ('p' + a);
}
return testArr;
})();
"#;
static ARRAY_CREATE: &str = include_str!("bench_scripts/array_create.js");
fn array_creation(c: &mut Criterion) {
c.bench_function("Array creation (Full)", move |b| {
@ -208,32 +114,7 @@ fn array_creation(c: &mut Criterion) {
});
}
static ARRAY_POP: &str = r#"
(function(){
let testArray = [83, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828,
234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62,
99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67,
77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29,
2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28,
83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32,
56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93,
27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93,
17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23,
56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36,
28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234,
23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99,
36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
45, 93, 17, 28, 83, 62, 99, 36, 28];
while (testArray.length > 0) {
testArray.pop();
}
return testArray;
})();
"#;
static ARRAY_POP: &str = include_str!("bench_scripts/array_pop.js");
fn array_pop(c: &mut Criterion) {
c.bench_function("Array pop (Full)", move |b| {
@ -241,14 +122,7 @@ fn array_pop(c: &mut Criterion) {
});
}
static STRING_CONCAT: &str = r#"
(function(){
var a = "hello";
var b = "world";
var c = a + b;
})();
"#;
static STRING_CONCAT: &str = include_str!("bench_scripts/string_concat.js");
fn string_concat(c: &mut Criterion) {
c.bench_function("String concatenation (Full)", move |b| {
@ -256,17 +130,7 @@ fn string_concat(c: &mut Criterion) {
});
}
static STRING_COMPARE: &str = r#"
(function(){
var a = "hello";
var b = "world";
var c = a == b;
var d = b;
var e = d == b;
})();
"#;
static STRING_COMPARE: &str = include_str!("bench_scripts/string_compare.js");
fn string_compare(c: &mut Criterion) {
c.bench_function("String comparison (Full)", move |b| {
@ -274,12 +138,7 @@ fn string_compare(c: &mut Criterion) {
});
}
static STRING_COPY: &str = r#"
(function(){
var a = "hello";
var b = a;
})();
"#;
static STRING_COPY: &str = include_str!("bench_scripts/string_copy.js");
fn string_copy(c: &mut Criterion) {
c.bench_function("String copy (Full)", move |b| {
@ -287,15 +146,7 @@ fn string_copy(c: &mut Criterion) {
});
}
static NUMBER_OBJECT_ACCESS: &str = r#"
new Number(
new Number(
new Number(
new Number(100).valueOf() - 10.5
).valueOf() + 100
).valueOf() * 1.6
)
"#;
static NUMBER_OBJECT_ACCESS: &str = include_str!("bench_scripts/number_object_access.js");
fn number_object_access(c: &mut Criterion) {
c.bench_function("Number Object Access (Full)", move |b| {
@ -303,15 +154,7 @@ fn number_object_access(c: &mut Criterion) {
});
}
static BOOLEAN_OBJECT_ACCESS: &str = r#"
new Boolean(
!new Boolean(
new Boolean(
!(new Boolean(false).valueOf()) && (new Boolean(true).valueOf())
).valueOf()
).valueOf()
).valueOf()
"#;
static BOOLEAN_OBJECT_ACCESS: &str = include_str!("bench_scripts/boolean_object_access.js");
fn boolean_object_access(c: &mut Criterion) {
c.bench_function("Boolean Object Access (Full)", move |b| {
@ -319,15 +162,7 @@ fn boolean_object_access(c: &mut Criterion) {
});
}
static STRING_OBJECT_ACCESS: &str = r#"
new String(
new String(
new String(
new String('Hello').valueOf() + new String(", world").valueOf()
).valueOf() + '!'
).valueOf()
).valueOf()
"#;
static STRING_OBJECT_ACCESS: &str = include_str!("bench_scripts/string_object_access.js");
fn string_object_access(c: &mut Criterion) {
c.bench_function("String Object Access (Full)", move |b| {
@ -335,9 +170,7 @@ fn string_object_access(c: &mut Criterion) {
});
}
static ARITHMETIC_OPERATIONS: &str = r#"
((2 + 2) ** 3 / 100 - 5 ** 3 * -1000) ** 2 + 100 - 8
"#;
static ARITHMETIC_OPERATIONS: &str = include_str!("bench_scripts/arithmetic_operations.js");
fn arithmetic_operations(c: &mut Criterion) {
c.bench_function("Arithmetic operations (Full)", move |b| {

18
boa/benches/lexer.rs

@ -10,9 +10,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
static EXPRESSION: &str = r#"
1 + 1 + 1 + 1 + 1 + 1 / 1 + 1 + 1 * 1 + 1 + 1 + 1;
"#;
static EXPRESSION: &str = include_str!("bench_scripts/expression.js");
fn expression_lexer(c: &mut Criterion) {
c.bench_function("Expression (Lexer)", move |b| {
@ -24,7 +22,7 @@ fn expression_lexer(c: &mut Criterion) {
});
}
static HELLO_WORLD: &str = "let foo = 'hello world!'; foo;";
static HELLO_WORLD: &str = include_str!("bench_scripts/hello_world.js");
fn hello_world_lexer(c: &mut Criterion) {
c.bench_function("Hello World (Lexer)", move |b| {
@ -37,17 +35,7 @@ fn hello_world_lexer(c: &mut Criterion) {
});
}
static FOR_LOOP: &str = r#"
for (let a = 10; a < 100; a++) {
if (a < 10) {
console.log("impossible D:");
} else if (a < 50) {
console.log("starting");
} else {
console.log("finishing");
}
}
"#;
static FOR_LOOP: &str = include_str!("bench_scripts/for_loop.js");
fn for_loop_lexer(c: &mut Criterion) {
c.bench_function("For loop (Lexer)", move |b| {

40
boa/benches/parser.rs

@ -10,9 +10,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
static EXPRESSION: &str = r#"
1 + 1 + 1 + 1 + 1 + 1 / 1 + 1 + 1 * 1 + 1 + 1 + 1;
"#;
static EXPRESSION: &str = include_str!("bench_scripts/expression.js");
fn expression_parser(c: &mut Criterion) {
// We include the lexing in the benchmarks, since they will get together soon, anyways.
@ -27,7 +25,7 @@ fn expression_parser(c: &mut Criterion) {
});
}
static HELLO_WORLD: &str = "let foo = 'hello world!'; foo;";
static HELLO_WORLD: &str = include_str!("bench_scripts/hello_world.js");
fn hello_world_parser(c: &mut Criterion) {
// We include the lexing in the benchmarks, since they will get together soon, anyways.
@ -42,17 +40,7 @@ fn hello_world_parser(c: &mut Criterion) {
});
}
static FOR_LOOP: &str = r#"
for (let a = 10; a < 100; a++) {
if (a < 10) {
console.log("impossible D:");
} else if (a < 50) {
console.log("starting");
} else {
console.log("finishing");
}
}
"#;
static FOR_LOOP: &str = include_str!("bench_scripts/for_loop.js");
fn for_loop_parser(c: &mut Criterion) {
// We include the lexing in the benchmarks, since they will get together soon, anyways.
@ -67,17 +55,7 @@ fn for_loop_parser(c: &mut Criterion) {
});
}
static LONG_REPETITION: &str = r#"
for (let a = 10; a < 100; a++) {
if (a < 10) {
console.log("impossible D:");
} else if (a < 50) {
console.log("starting");
} else {
console.log("finishing");
}
}
"#;
static LONG_REPETITION: &str = include_str!("bench_scripts/long_repetition.js");
fn long_file_parser(c: &mut Criterion) {
use std::{
@ -111,15 +89,7 @@ fn long_file_parser(c: &mut Criterion) {
fs::remove_file(FILE_NAME).unwrap_or_else(|_| panic!("could not remove {}", FILE_NAME));
}
static GOAL_SYMBOL_SWITCH: &str = r#"
function foo(regex, num) {}
let i = 0;
while (i < 1000000) {
foo(/ab+c/, 5.0/5);
i++;
}
"#;
static GOAL_SYMBOL_SWITCH: &str = include_str!("bench_scripts/goal_symbol_switch.js");
fn goal_symbol_switch(c: &mut Criterion) {
// We include the lexing in the benchmarks, since they will get together soon, anyways.

Loading…
Cancel
Save