use criterion::Criterion;
use criterion::{black_box, criterion_group, criterion_main};
fn bench() {
let ops = roar::bc::parse_bytecode(b"lcs c4c5 cg ccccf cgc>p + c+ c* cgc>v *").unwrap();
let consts = vec![
roar::bc::BytecodeValue::I64(0),
roar::bc::BytecodeValue::F64(1.0 / 300.0),
roar::bc::BytecodeValue::F64(1.0 / 300.0),
roar::bc::BytecodeValue::I64(0),
roar::bc::BytecodeValue::I64(6),
roar::bc::BytecodeValue::F64(1.3),
roar::bc::BytecodeValue::F64(2.0),
roar::bc::BytecodeValue::F64(0.5),
roar::bc::BytecodeValue::I64(0),
roar::bc::BytecodeValue::I64(2),
roar::bc::BytecodeValue::F64(1.0),
roar::bc::BytecodeValue::F64(0.5),
roar::bc::BytecodeValue::I64(0),
roar::bc::BytecodeValue::I64(7),
];
let buf = vec![roar::bc::BytecodeValue::I64(black_box(0x32534652))];
let runtime = roar::runtime::Runtime::new(black_box(ops), black_box(consts), black_box(buf));
for y in 0..16 {
for x in 0..16 {
let mut frame = runtime.create_frame([x.into(), y.into()]);
let _val = black_box(frame.run()).unwrap();
}
}
}
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("runtime_bench", |b| b.iter(bench));
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);