MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / tinywasm_run

Function tinywasm_run

crates/tinywasm/benches/tinywasm.rs:25–34  ·  view source on GitHub ↗
(module: &Module)

Source from the content-addressed store, hash-verified

23}
24
25fn tinywasm_run(module: &Module) -> Result<()> {
26 let engine = Engine::new(Config::default().with_memory_backend(MemoryBackend::paged(64 * 1024)));
27 let mut store = Store::new(engine);
28 let mut imports = Imports::default();
29 imports.define("env", "printi32", HostFunction::from(&mut store, |_: FuncContext<'_>, _: i32| Ok(())));
30 let instance = ModuleInstance::instantiate(&mut store, module, Some(imports)).expect("instantiate");
31 let hello = instance.func::<(), ()>(&store, "hello").expect("func_typed");
32 hello.call(&mut store, ()).expect("call");
33 Ok(())
34}
35
36fn criterion_benchmark(c: &mut Criterion) {
37 let module = tinywasm_parse().expect("tinywasm_parse");

Callers 1

criterion_benchmarkFunction · 0.85

Calls 3

with_memory_backendMethod · 0.80
defineMethod · 0.80
callMethod · 0.80

Tested by

no test coverage detected