From 868aa006b7f1eabffd4aec3a03555012148a7df1 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Fri, 10 May 2024 18:08:00 +0200 Subject: chore: slight perf improvements Signed-off-by: Henry Gressmann --- benchmarks/benches/fibonacci.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'benchmarks/benches/fibonacci.rs') diff --git a/benchmarks/benches/fibonacci.rs b/benchmarks/benches/fibonacci.rs index b391285..15c09ac 100644 --- a/benchmarks/benches/fibonacci.rs +++ b/benchmarks/benches/fibonacci.rs @@ -1,9 +1,8 @@ mod util; use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use util::wasm_to_twasm; -fn run_tinywasm(twasm: &[u8], iterations: i32, name: &str) { - let (mut store, instance) = util::tinywasm(twasm); +fn run_tinywasm(wasm: &[u8], iterations: i32, name: &str) { + let (mut store, instance) = util::tinywasm(wasm); let fib = instance.exported_func::(&store, name).expect("exported_func"); fib.call(&mut store, iterations).expect("call"); } @@ -47,12 +46,10 @@ fn run_native_recursive(n: i32) -> i32 { const FIBONACCI: &[u8] = include_bytes!("../../examples/rust/out/fibonacci.wasm"); fn criterion_benchmark(c: &mut Criterion) { - let twasm = wasm_to_twasm(FIBONACCI); - { let mut group = c.benchmark_group("fibonacci"); group.bench_function("native", |b| b.iter(|| run_native(black_box(60)))); - group.bench_function("tinywasm", |b| b.iter(|| run_tinywasm(&twasm, black_box(60), "fibonacci"))); + group.bench_function("tinywasm", |b| b.iter(|| run_tinywasm(FIBONACCI, black_box(60), "fibonacci"))); group.bench_function("wasmi", |b| b.iter(|| run_wasmi(FIBONACCI, black_box(60), "fibonacci"))); group.bench_function("wasmer", |b| b.iter(|| run_wasmer(FIBONACCI, black_box(60), "fibonacci"))); } @@ -61,7 +58,7 @@ fn criterion_benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("fibonacci-recursive"); group.measurement_time(std::time::Duration::from_secs(5)); group.bench_function("native", |b| b.iter(|| run_native_recursive(black_box(26)))); - group.bench_function("tinywasm", |b| b.iter(|| run_tinywasm(&twasm, black_box(26), "fibonacci_recursive"))); + group.bench_function("tinywasm", |b| b.iter(|| run_tinywasm(FIBONACCI, black_box(26), "fibonacci_recursive"))); group.bench_function("wasmi", |b| b.iter(|| run_wasmi(FIBONACCI, black_box(26), "fibonacci_recursive"))); group.bench_function("wasmer", |b| b.iter(|| run_wasmer(FIBONACCI, black_box(26), "fibonacci_recursive"))); } -- cgit v1.3.1