mirror of https://github.com/boa-dev/boa.git
Jason Williams
5 years ago
4 changed files with 64 additions and 7 deletions
@ -0,0 +1,30 @@
|
||||
#[macro_use] |
||||
extern crate criterion; |
||||
|
||||
use boa::exec; |
||||
use boa::syntax::lexer::Lexer; |
||||
use boa::syntax::parser::Parser; |
||||
use criterion::black_box; |
||||
use criterion::Criterion; |
||||
|
||||
static SRC: &str = r#" |
||||
let num = 12; |
||||
|
||||
function fib(n) { |
||||
if (n <= 1) return 1; |
||||
return fib(n - 1) + fib(n - 2); |
||||
} |
||||
|
||||
let res = fib(num); |
||||
|
||||
res; |
||||
"#; |
||||
|
||||
fn fibonacci(c: &mut Criterion) { |
||||
c.bench_function("fibonacci (Execution)", move |b| { |
||||
b.iter(|| exec(black_box(SRC))) |
||||
}); |
||||
} |
||||
|
||||
criterion_group!(benches, fibonacci); |
||||
criterion_main!(benches); |
Loading…
Reference in new issue