Skip to content

Commit

Permalink
Added string benchmarks, and updated dependencies (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican authored Jun 14, 2020
1 parent d042ddd commit d2939ff
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 18 deletions.
25 changes: 13 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions boa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ edition = "2018"
profiler = ["measureme", "once_cell"]

[dependencies]
gc = { version = "0.3.5", features = ["derive"] }
serde_json = "1.0.53"
gc = { version = "0.3.6", features = ["derive"] }
serde_json = "1.0.55"
rand = "0.7.3"
num-traits = "0.2.11"
num-traits = "0.2.12"
regex = "1.3.9"
rustc-hash = "1.1.0"
num-bigint = { version = "0.2.6", features = ["serde"] }
num-integer = "0.1.42"
num-bigint = { version = "0.3.0", features = ["serde"] }
num-integer = "0.1.43"
bitflags = "1.2.1"

# Optional Dependencies
Expand Down
73 changes: 73 additions & 0 deletions boa/benches/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,76 @@ fn array_pop(c: &mut Criterion) {
});
}

static STRING_CONCAT: &str = r#"
(function(){
var a = "hello";
var b = "world";
var c = a + b;
})();
"#;

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

let mut lexer = Lexer::new(black_box(STRING_CONCAT));
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&black_box(lexer.tokens)).parse_all().unwrap();

c.bench_function("String concatenation (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
});
}

static STRING_COMPARE: &str = r#"
(function(){
var a = "hello";
var b = "world";
var c = a == b;
var d = b;
var e = d == b;
})();
"#;

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

let mut lexer = Lexer::new(black_box(STRING_COMPARE));
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&black_box(lexer.tokens)).parse_all().unwrap();

c.bench_function("String comparison (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
});
}

static STRING_COPY: &str = r#"
(function(){
var a = "hello";
var b = a;
})();
"#;

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

let mut lexer = Lexer::new(black_box(STRING_COPY));
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&black_box(lexer.tokens)).parse_all().unwrap();

c.bench_function("String copy (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
});
}

criterion_group!(
execution,
create_realm,
Expand All @@ -397,5 +467,8 @@ criterion_group!(
regexp_creation,
regexp_literal,
regexp,
string_concat,
string_compare,
string_copy,
);
criterion_main!(execution);
2 changes: 1 addition & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2018"
[dependencies]
Boa = { path = "../boa", features = ["serde"] }
structopt = "0.3.14"
serde_json = "1.0.53"
serde_json = "1.0.55"

[target.x86_64-unknown-linux-gnu.dependencies]
jemallocator = "0.3.2"
Expand Down

0 comments on commit d2939ff

Please sign in to comment.