def test_benchmark_headless_time_nbody_cranelift_jit(benchmark): store = Store(engine.JIT(Cranelift)) module = Module(store, TEST_BYTES) serialized = module.serialize() @benchmark def bench(): deserialized = Module.deserialize(store, serialized) _ = Instance(deserialized)
def test_benchmark_headless_time_nbody_singlepass_native(benchmark): store = Store(engine.Native(Singlepass)) module = Module(store, TEST_BYTES) serialized = module.serialize() @benchmark def bench(): deserialized = Module.deserialize(store, serialized) _ = Instance(deserialized)
# # In this case, the engine is `wasmer.engine.Dylib` which means that # a native object is going to be generated. So when we are going to # serialize the compiled Wasm module, we are going to store it in a # file with the `.so` extension for example (or `.dylib`, or `.dll` # depending of the platform). engine = engine.Dylib(Compiler) # Create a store, that holds the engine. store = Store(engine) # Let's compile the Wasm module. module = Module(store, wasm_bytes) # Here we go. Let's serialize the compiled Wasm module in a file. serialized_module = module.serialize() serialized_module_file = tempfile.TemporaryFile() serialized_module_file.write(serialized_module) # We seek to the initial position, so when we read it starts from the beginning serialized_module_file.seek(0, 0) # Second step, deserialize the compiled Wasm module, and execute it, # for example with Wasmer without a compiler. from wasmer import engine, Store, Instance, Module # We create a headless Dylib engine, i.e. an engine without a # compiler. engine = engine.Dylib()