Skip to content

Commit

Permalink
Added benchmark for goal symbol switching (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican authored Jul 8, 2020
1 parent 84db01e commit 8b3d52b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

24 changes: 24 additions & 0 deletions boa/benches/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,35 @@ 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++;
}
"#;

fn goal_symbol_switch(c: &mut Criterion) {
// We include the lexing in the benchmarks, since they will get together soon, anyways.

c.bench_function("Goal Symbols (Parser)", move |b| {
b.iter(|| {
let mut lexer = Lexer::new(black_box(GOAL_SYMBOL_SWITCH));
lexer.lex().expect("failed to lex");

Parser::new(&black_box(lexer.tokens)).parse_all()
})
});
}

criterion_group!(
parser,
expression_parser,
hello_world_parser,
for_loop_parser,
long_file_parser,
goal_symbol_switch,
);
criterion_main!(parser);
6 changes: 6 additions & 0 deletions boa/src/builtins/math/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ fn ceil() {
}

#[test]
#[allow(clippy::many_single_char_names)]
fn clz32() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
Expand Down Expand Up @@ -280,6 +281,7 @@ fn exp() {
}

#[test]
#[allow(clippy::many_single_char_names)]
fn expm1() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
Expand Down Expand Up @@ -331,6 +333,7 @@ fn floor() {
}

#[test]
#[allow(clippy::many_single_char_names)]
fn fround() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
Expand Down Expand Up @@ -364,6 +367,7 @@ fn fround() {
}

#[test]
#[allow(clippy::many_single_char_names)]
fn hypot() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
Expand Down Expand Up @@ -397,6 +401,7 @@ fn hypot() {
}

#[test]
#[allow(clippy::many_single_char_names)]
fn imul() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
Expand Down Expand Up @@ -448,6 +453,7 @@ fn log() {
}

#[test]
#[allow(clippy::many_single_char_names)]
fn log1p() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
Expand Down

0 comments on commit 8b3d52b

Please sign in to comment.