mirror of
https://github.com/fluencelabs/aquavm
synced 2025-03-15 20:40:50 +00:00
chore(tests): etalon benchmarking test for network team convenience (#754)
This commit is contained in:
parent
a8965e04ec
commit
973e8aeea5
@ -85,3 +85,7 @@ harness = false
|
|||||||
[[bench]]
|
[[bench]]
|
||||||
name = "data_long_benchmark"
|
name = "data_long_benchmark"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "nox_tc2_benchmark"
|
||||||
|
harness = false
|
40
air/benches/nox_tc2_benchmark.rs
Normal file
40
air/benches/nox_tc2_benchmark.rs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
use air_test_utils::prelude::*;
|
||||||
|
|
||||||
|
use criterion::criterion_group;
|
||||||
|
use criterion::criterion_main;
|
||||||
|
use criterion::Criterion;
|
||||||
|
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
thread_local!(static VM: RefCell<TestRunner<ReleaseWasmAirRunner>> = RefCell::new(
|
||||||
|
create_custom_avm(unit_call_service(), "test_peer_id"))
|
||||||
|
);
|
||||||
|
thread_local!(static SCRIPT: String = String::from(
|
||||||
|
r#"
|
||||||
|
(seq
|
||||||
|
(ap "123" $stream)
|
||||||
|
(canon "test_peer_id" $stream #stream-canon)
|
||||||
|
)
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
fn nox_tc2_benchmark() -> 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)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
c.bench_function("nox_tc2_benchmark", move |b: &mut criterion::Bencher<'_>| {
|
||||||
|
b.iter(nox_tc2_benchmark)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group! {
|
||||||
|
name = benches;
|
||||||
|
// This can be any expression that returns a `Criterion` object.
|
||||||
|
config = Criterion::default().measurement_time(Duration::from_secs(10));
|
||||||
|
targets = criterion_benchmark
|
||||||
|
}
|
||||||
|
criterion_main!(benches);
|
Loading…
x
Reference in New Issue
Block a user