Skip to content

Commit cf5634e

Browse files
committed
Updates.
1 parent 61bc7ff commit cf5634e

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

benches/table_fill.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use criterion::{criterion_group, criterion_main, Criterion};
22
use std::time::Duration;
33

4-
/// Number of elements to be filled in the benchmarked table.
5-
const LENGTHS: [usize; 9] = [0, 1, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 9_999_999];
4+
/// Lengths used for benchmarking.
5+
const LENGTHS: [usize; 23] = [
6+
0, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1_000, 2_000, 5_000, 10_000, 20_000, 50_000, 100_000, 200_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 9_999_999,
7+
];
68

79
const TEMPLATE: &str = r#"
810
(module
@@ -58,11 +60,22 @@ fn _0001(c: &mut Criterion) {
5860
for length in LENGTHS {
5961
let wasm_bytes = wat::parse_str(wat_source(length)).unwrap();
6062
let compiler = wasmer::sys::Singlepass::default();
61-
let mut store = wasmer::Store::new(compiler);
63+
let store = wasmer::Store::new(compiler);
6264
let module = wasmer::Module::from_binary(&store, &wasm_bytes).unwrap();
63-
let instance = wasmer::Instance::new(&mut store, &module, &wasmer::imports! {}).unwrap();
64-
let fun = instance.exports.get_typed_function::<(), ()>(&store, "fun").unwrap();
65-
group.bench_with_input(format!("length = {length}"), &length, |b, &_| b.iter(|| fun.call(&mut store).unwrap()));
65+
group.bench_with_input(format!("length = {length}"), &length, |b, _| {
66+
b.iter_batched(
67+
|| {
68+
let mut store = wasmer::Store::new(wasmer::sys::Singlepass::default());
69+
let instance = wasmer::Instance::new(&mut store, &module, &wasmer::imports! {}).unwrap();
70+
let fun = instance.exports.get_typed_function::<(), ()>(&store, "fun").unwrap();
71+
(store, fun)
72+
},
73+
|(mut store, fun)| {
74+
fun.call(&mut store).unwrap();
75+
},
76+
criterion::BatchSize::LargeInput,
77+
);
78+
});
6679
}
6780
}
6881

0 commit comments

Comments
 (0)