Skip to content

Commit

Permalink
Merge 3c89202 into 460b4a2
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat authored Sep 2, 2020
2 parents 460b4a2 + 3c89202 commit 2950f6f
Show file tree
Hide file tree
Showing 74 changed files with 1,472 additions and 1,858 deletions.
68 changes: 23 additions & 45 deletions boa/benches/exec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Benchmarks of the whole execution engine in Boa.

use boa::{exec::Interpreter, realm::Realm, Executable, Parser};
use boa::{exec::Executable, realm::Realm, syntax::Parser, Context};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
Expand All @@ -18,8 +18,7 @@ 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();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(SYMBOL_CREATION.as_bytes()).parse_all().unwrap();
Expand All @@ -34,8 +33,7 @@ static FOR_LOOP: &str = include_str!("bench_scripts/for_loop.js");

fn for_loop_execution(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(FOR_LOOP.as_bytes()).parse_all().unwrap();
Expand All @@ -50,8 +48,7 @@ static FIBONACCI: &str = include_str!("bench_scripts/fibonacci.js");

fn fibonacci(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(FIBONACCI.as_bytes()).parse_all().unwrap();
Expand All @@ -66,8 +63,7 @@ static OBJECT_CREATION: &str = include_str!("bench_scripts/object_creation.js");

fn object_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(OBJECT_CREATION.as_bytes()).parse_all().unwrap();
Expand All @@ -82,8 +78,7 @@ static OBJECT_PROP_ACCESS_CONST: &str = include_str!("bench_scripts/object_prop_

fn object_prop_access_const(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(OBJECT_PROP_ACCESS_CONST.as_bytes())
Expand All @@ -100,8 +95,7 @@ static OBJECT_PROP_ACCESS_DYN: &str = include_str!("bench_scripts/object_prop_ac

fn object_prop_access_dyn(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(OBJECT_PROP_ACCESS_DYN.as_bytes())
Expand All @@ -118,8 +112,7 @@ static REGEXP_LITERAL_CREATION: &str = include_str!("bench_scripts/regexp_litera

fn regexp_literal_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(REGEXP_LITERAL_CREATION.as_bytes())
Expand All @@ -136,8 +129,7 @@ static REGEXP_CREATION: &str = include_str!("bench_scripts/regexp_creation.js");

fn regexp_creation(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(REGEXP_CREATION.as_bytes()).parse_all().unwrap();
Expand All @@ -152,8 +144,7 @@ static REGEXP_LITERAL: &str = include_str!("bench_scripts/regexp_literal.js");

fn regexp_literal(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(REGEXP_LITERAL.as_bytes()).parse_all().unwrap();
Expand All @@ -168,8 +159,7 @@ static REGEXP: &str = include_str!("bench_scripts/regexp.js");

fn regexp(c: &mut Criterion) {
// Create new Realm and interpreter.
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

// Parse the AST nodes.
let nodes = Parser::new(REGEXP.as_bytes()).parse_all().unwrap();
Expand All @@ -183,8 +173,7 @@ fn regexp(c: &mut Criterion) {
static ARRAY_ACCESS: &str = include_str!("bench_scripts/array_access.js");

fn array_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(ARRAY_ACCESS.as_bytes()).parse_all().unwrap();

Expand All @@ -196,8 +185,7 @@ fn array_access(c: &mut Criterion) {
static ARRAY_CREATE: &str = include_str!("bench_scripts/array_create.js");

fn array_creation(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(ARRAY_CREATE.as_bytes()).parse_all().unwrap();

Expand All @@ -209,8 +197,7 @@ fn array_creation(c: &mut Criterion) {
static ARRAY_POP: &str = include_str!("bench_scripts/array_pop.js");

fn array_pop(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(ARRAY_POP.as_bytes()).parse_all().unwrap();

Expand All @@ -222,8 +209,7 @@ fn array_pop(c: &mut Criterion) {
static STRING_CONCAT: &str = include_str!("bench_scripts/string_concat.js");

fn string_concat(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(STRING_CONCAT.as_bytes()).parse_all().unwrap();

Expand All @@ -235,8 +221,7 @@ fn string_concat(c: &mut Criterion) {
static STRING_COMPARE: &str = include_str!("bench_scripts/string_compare.js");

fn string_compare(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(STRING_COMPARE.as_bytes()).parse_all().unwrap();

Expand All @@ -248,8 +233,7 @@ fn string_compare(c: &mut Criterion) {
static STRING_COPY: &str = include_str!("bench_scripts/string_copy.js");

fn string_copy(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(STRING_COPY.as_bytes()).parse_all().unwrap();

Expand All @@ -261,8 +245,7 @@ fn string_copy(c: &mut Criterion) {
static NUMBER_OBJECT_ACCESS: &str = include_str!("bench_scripts/number_object_access.js");

fn number_object_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(NUMBER_OBJECT_ACCESS.as_bytes())
.parse_all()
Expand All @@ -276,8 +259,7 @@ fn number_object_access(c: &mut Criterion) {
static BOOLEAN_OBJECT_ACCESS: &str = include_str!("bench_scripts/boolean_object_access.js");

fn boolean_object_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(BOOLEAN_OBJECT_ACCESS.as_bytes())
.parse_all()
Expand All @@ -291,8 +273,7 @@ fn boolean_object_access(c: &mut Criterion) {
static STRING_OBJECT_ACCESS: &str = include_str!("bench_scripts/string_object_access.js");

fn string_object_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(STRING_OBJECT_ACCESS.as_bytes())
.parse_all()
Expand All @@ -306,8 +287,7 @@ fn string_object_access(c: &mut Criterion) {
static ARITHMETIC_OPERATIONS: &str = include_str!("bench_scripts/arithmetic_operations.js");

fn arithmetic_operations(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();

let nodes = Parser::new(ARITHMETIC_OPERATIONS.as_bytes())
.parse_all()
Expand All @@ -321,8 +301,7 @@ fn arithmetic_operations(c: &mut Criterion) {
static CLEAN_JS: &str = include_str!("bench_scripts/clean_js.js");

fn clean_js(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();
let nodes = Parser::new(CLEAN_JS.as_bytes()).parse_all().unwrap();
c.bench_function("Clean js (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -332,8 +311,7 @@ fn clean_js(c: &mut Criterion) {
static MINI_JS: &str = include_str!("bench_scripts/mini_js.js");

fn mini_js(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let mut engine = Context::new();
let nodes = Parser::new(MINI_JS.as_bytes()).parse_all().unwrap();
c.bench_function("Mini js (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand Down
Loading

0 comments on commit 2950f6f

Please sign in to comment.