diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-01 21:49:12 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-01 21:49:29 +0100 |
| commit | f9b6a64b845dabdf1773da49f248def479659934 (patch) | |
| tree | f434d4606f5827d393c20712e2a527a9395d6ad7 /benches/sylt_benchmark.rs | |
| parent | 8089ff61f5ca608e0801e74360203c6fd789b5d7 (diff) | |
| download | sylt-f9b6a64b845dabdf1773da49f248def479659934.tar.gz | |
tihdy -> sylt
Diffstat (limited to 'benches/sylt_benchmark.rs')
| -rw-r--r-- | benches/sylt_benchmark.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/benches/sylt_benchmark.rs b/benches/sylt_benchmark.rs new file mode 100644 index 0000000..a68a762 --- /dev/null +++ b/benches/sylt_benchmark.rs @@ -0,0 +1,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 = sylt::compiler::compile("main", Path::new("prog"), sylt::tokenizer::string_to_tokens(prog)).unwrap(); + c.bench_function("fib 50", |b| b.iter(|| sylt::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 = sylt::compiler::compile("main", Path::new("prog"), sylt::tokenizer::string_to_tokens(prog)).unwrap(); + c.bench_function("fib 90", |b| b.iter(|| sylt::vm::run_block(&compiled).unwrap())); +} + +criterion_group!(benches, fib_50, fib_90); +criterion_main!(benches); |
