11use criterion:: { black_box, criterion_group, criterion_main, BenchmarkId , Criterion } ;
22use mun_runtime:: StructRef ;
3+ use wasmer:: Store ;
34
45mod util;
56
@@ -9,7 +10,9 @@ pub fn fibonacci_benchmark(c: &mut Criterion) {
910 // Perform setup (not part of the benchmark)
1011 let runtime = util:: runtime_from_file ( "fibonacci.mun" ) ;
1112 let lua = util:: lua_from_file ( "fibonacci.lua" ) ;
12- let wasm = util:: wasmer_from_file ( "fibonacci.wasm" ) ;
13+ let wasm_store = Store :: default ( ) ;
14+ let wasm = util:: wasmer_from_file ( & wasm_store, "fibonacci.wasm" ) ;
15+ let wasm_func = wasm. exports . get_function ( "main" ) . unwrap ( ) ;
1316
1417 let mut group = c. benchmark_group ( "fibonacci" ) ;
1518
@@ -38,7 +41,7 @@ pub fn fibonacci_benchmark(c: &mut Criterion) {
3841 // Run Wasm fibonacci
3942 group. bench_with_input ( BenchmarkId :: new ( "wasm" , i) , i, |b, i| {
4043 b. iter ( || {
41- wasm . call ( "main" , & [ ( * i as i32 ) . into ( ) ] ) . unwrap ( ) ;
44+ wasm_func . call ( & [ ( * i as i32 ) . into ( ) ] ) . unwrap ( ) ;
4245 } )
4346 } ) ;
4447 }
@@ -72,7 +75,9 @@ pub fn empty_benchmark(c: &mut Criterion) {
7275 // Perform setup (not part of the benchmark)
7376 let runtime = util:: runtime_from_file ( "empty.mun" ) ;
7477 let lua = util:: lua_from_file ( "empty.lua" ) ;
75- let wasm = util:: wasmer_from_file ( "empty.wasm" ) ;
78+ let wasm_store = Store :: default ( ) ;
79+ let wasm = util:: wasmer_from_file ( & wasm_store, "empty.wasm" ) ;
80+ let wasm_func = wasm. exports . get_function ( "empty" ) . unwrap ( ) ;
7681
7782 let mut group = c. benchmark_group ( "empty" ) ;
7883
@@ -89,7 +94,7 @@ pub fn empty_benchmark(c: &mut Criterion) {
8994 } )
9095 } ) ;
9196 group. bench_function ( "wasm" , |b| {
92- b. iter ( || wasm . call ( "empty" , & [ black_box ( 20i64 ) . into ( ) ] ) )
97+ b. iter ( || wasm_func . call ( & [ black_box ( 20i64 ) . into ( ) ] ) )
9398 } ) ;
9499
95100 group. finish ( ) ;
0 commit comments