1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
use criterion::{criterion_group, criterion_main, Criterion};
use std::path::Path;
pub fn fib_50(c: &mut Criterion) {
let prog =
"
j := 0
for , j < 1000, j = j + 1 {
a := 0
b := 1
for i := 0, i < 50, i = i + 1 {
c := a
a = b
b = c + b
}
a <=> 12586269025
}
";
let compiled = tihdy::compiler::compile("main", Path::new("prog"), tihdy::tokenizer::string_to_tokens(prog)).unwrap();
c.bench_function("fib 50", |b| b.iter(|| tihdy::vm::run_block(&compiled).unwrap()));
}
pub fn fib_90(c: &mut Criterion) {
let prog =
"
a := 0
b := 1
for i := 0, i < 90, i = i + 1 {
c := a
a = b
b = c + b
}
a <=> 2880067194370816120
";
let compiled = tihdy::compiler::compile("main", Path::new("prog"), tihdy::tokenizer::string_to_tokens(prog)).unwrap();
c.bench_function("fib 90", |b| b.iter(|| tihdy::vm::run_block(&compiled).unwrap()));
}
criterion_group!(benches, fib_50, fib_90);
criterion_main!(benches);
|