aquavm/air/benches/call_benchmark.rs

30 lines
904 B
Rust
Raw Normal View History

use air_test_utils::prelude::*;
2020-11-01 17:20:25 +03:00
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::Criterion;
use std::cell::RefCell;
thread_local!(static VM: RefCell<TestRunner<ReleaseWasmAirRunner>> = RefCell::new(
create_custom_avm(unit_call_service(), "test_peer_id"))
);
2020-11-01 17:20:25 +03:00
thread_local!(static SCRIPT: String = String::from(
r#"
2020-12-28 00:12:11 +03:00
(call "test_peer_id" ("local_service_id" "local_fn_name") [] result_name)
2020-11-01 17:20:25 +03:00
"#,
)
);
fn current_peer_id_call() -> Result<RawAVMOutcome, String> {
let run_parameters = TestRunParameters::new("test_peer_id", 0, 1, "");
VM.with(|vm| SCRIPT.with(|script| vm.borrow_mut().call(script, "", "", run_parameters)))
2020-11-01 17:20:25 +03:00
}
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("current_peer_id_call", move |b| b.iter(current_peer_id_call));
2020-11-01 17:20:25 +03:00
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);