mirror of https://github.com/boa-dev/boa.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
777 B
31 lines
777 B
5 years ago
|
#[macro_use]
|
||
|
extern crate criterion;
|
||
|
|
||
|
use boa::syntax::lexer::Lexer;
|
||
|
use boa::syntax::parser::Parser;
|
||
|
use criterion::black_box;
|
||
|
use criterion::Criterion;
|
||
|
|
||
|
static EXPRESSION: &str = r#"
|
||
|
1 + 1 + 1 + 1 + 1 + 1 / 1 + 1 + 1 * 1 + 1 + 1 + 1;
|
||
|
"#;
|
||
|
|
||
|
fn expression_parser(c: &mut Criterion) {
|
||
|
// Don't include lexing as part of the parser benchmark
|
||
|
let mut lexer = Lexer::new(EXPRESSION);
|
||
|
lexer.lex().expect("failed to lex");
|
||
|
let tokens = lexer.tokens;
|
||
|
c.bench_function_over_inputs(
|
||
|
"Expression (Parser)",
|
||
|
move |b, tok| {
|
||
|
b.iter(|| {
|
||
|
Parser::new(black_box(tok.to_vec())).parse_all().unwrap();
|
||
|
})
|
||
|
},
|
||
|
vec![tokens],
|
||
|
);
|
||
|
}
|
||
|
|
||
|
criterion_group!(benches, expression_parser);
|
||
|
criterion_main!(benches);
|