Files
wazero/internal/engine/compiler/engine_bench_test.go
Nuno Cruces 90f58bce75 compiler: fix compiledModule leak (#1608)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
2023-08-02 09:14:49 +08:00

46 lines
1.1 KiB
Go

package compiler
import (
"context"
"testing"
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/experimental"
"github.com/tetratelabs/wazero/internal/wasm"
)
func BenchmarkCallEngine_builtinFunctionFunctionListener(b *testing.B) {
f := &function{
funcType: &wasm.FunctionType{ParamNumInUint64: 3},
parent: &compiledFunction{
listener: mockListener{
before: func(context.Context, api.Module, api.FunctionDefinition, []uint64, experimental.StackIterator) {
},
after: func(context.Context, api.Module, api.FunctionDefinition, []uint64) {
},
},
index: 0,
parent: &compiledCode{
source: &wasm.Module{
TypeSection: []wasm.FunctionType{{}},
FunctionSection: []wasm.Index{0},
CodeSection: []wasm.Code{{Body: []byte{wasm.OpcodeEnd}}},
},
},
},
}
ce := &callEngine{
stack: []uint64{0, 1, 2, 3, 4, 0, 0, 0},
stackContext: stackContext{stackBasePointerInBytes: 16},
}
mod := new(wasm.ModuleInstance)
ctx := context.Background()
for i := 0; i < b.N; i++ {
ce.builtinFunctionFunctionListenerBefore(ctx, mod, f)
ce.builtinFunctionFunctionListenerAfter(ctx, mod, f)
}
}