Files
wazero/internal/integration_test/vs/bench_shorthash.go
Crypt Keeper d3c5e8655f Adds benchmarks from lib sodium (#948)
This adds benchmarks from lib sodium, but the results are hard to interpret. We may need to recompile them using zig so that we can export a function instead of using WASI to do it. Right now, we can't really see performance of functions because other runtimes aren't designed to re-instantiate like ours.

This only compares against wasmtime as that's the only runtime besides
ours that is safe to re-instantiate.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-12-21 09:17:13 +08:00

34 lines
834 B
Go

package vs
import (
_ "embed"
"testing"
)
var (
// shorthashWasm is a wasi binary which runs the same wasm function inside
// a loop. See https://github.com/tetratelabs/wazero/issues/947
//
// Taken from https://github.com/jedisct1/webassembly-benchmarks/tree/master/2022-12/wasm
//go:embed testdata/shorthash.wasm
shorthashWasm []byte
shorthashConfig *RuntimeConfig
)
func init() {
shorthashConfig = &RuntimeConfig{
ModuleName: "shorthash",
ModuleWasm: shorthashWasm,
NeedsWASI: true, // runs as a _start function
}
}
func RunTestShorthash(t *testing.T, runtime func() Runtime) {
// not testCall as there are no exported functions except _start
testInstantiate(t, runtime, shorthashConfig)
}
func RunBenchmarkShorthash(b *testing.B, runtime func() Runtime) {
benchmark(b, runtime, shorthashConfig, nil)
}