Skip to content

Commit

Permalink
Merge 7facc31 into c7531af
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat authored Aug 25, 2020
2 parents c7531af + 7facc31 commit 5b4f38a
Show file tree
Hide file tree
Showing 72 changed files with 1,360 additions and 1,744 deletions.
73 changes: 28 additions & 45 deletions boa/benches/exec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//! Benchmarks of the whole execution engine in Boa.
use boa::{exec::Interpreter, realm::Realm, Executable, Lexer, Parser};
use boa::{
context::Context,
exec::Executable,
realm::Realm,
syntax::{Lexer, Parser},
};
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 +23,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();

// Lex all the tokens.
let mut lexer = Lexer::new(SYMBOL_CREATION);
Expand All @@ -38,8 +42,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();

// Lex all the tokens.
let mut lexer = Lexer::new(FOR_LOOP);
Expand All @@ -58,8 +61,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();

// Lex all the tokens.
let mut lexer = Lexer::new(FIBONACCI);
Expand All @@ -78,8 +80,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();

// Lex all the tokens.
let mut lexer = Lexer::new(OBJECT_CREATION);
Expand All @@ -98,8 +99,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();

// Lex all the tokens.
let mut lexer = Lexer::new(OBJECT_PROP_ACCESS_CONST);
Expand All @@ -118,8 +118,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();

// Lex all the tokens.
let mut lexer = Lexer::new(OBJECT_PROP_ACCESS_DYN);
Expand All @@ -138,8 +137,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();

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP_LITERAL_CREATION);
Expand All @@ -158,8 +156,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();

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP_CREATION);
Expand All @@ -178,8 +175,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();

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP_LITERAL);
Expand All @@ -198,8 +194,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();

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP);
Expand All @@ -217,8 +212,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 mut lexer = Lexer::new(ARRAY_ACCESS);
lexer.lex().expect("failed to lex");
Expand All @@ -233,8 +227,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 mut lexer = Lexer::new(ARRAY_CREATE);
lexer.lex().expect("failed to lex");
Expand All @@ -249,8 +242,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 mut lexer = Lexer::new(ARRAY_POP);
lexer.lex().expect("failed to lex");
Expand All @@ -265,8 +257,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 mut lexer = Lexer::new(STRING_CONCAT);
lexer.lex().expect("failed to lex");
Expand All @@ -281,8 +272,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 mut lexer = Lexer::new(STRING_COMPARE);
lexer.lex().expect("failed to lex");
Expand All @@ -297,8 +287,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 mut lexer = Lexer::new(STRING_COPY);
lexer.lex().expect("failed to lex");
Expand All @@ -313,8 +302,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 mut lexer = Lexer::new(NUMBER_OBJECT_ACCESS);
lexer.lex().expect("failed to lex");
Expand All @@ -329,8 +317,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 mut lexer = Lexer::new(BOOLEAN_OBJECT_ACCESS);
lexer.lex().expect("failed to lex");
Expand All @@ -345,8 +332,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 mut lexer = Lexer::new(STRING_OBJECT_ACCESS);
lexer.lex().expect("failed to lex");
Expand All @@ -361,8 +347,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 mut lexer = Lexer::new(ARITHMETIC_OPERATIONS);
lexer.lex().expect("failed to lex");
Expand All @@ -377,8 +362,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 mut lexer = Lexer::new(CLEAN_JS);
lexer.lex().expect("failed to lex");
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
Expand All @@ -390,8 +374,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 mut lexer = Lexer::new(MINI_JS);
lexer.lex().expect("failed to lex");
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
Expand Down
Loading

0 comments on commit 5b4f38a

Please sign in to comment.