github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/engine/compiler/engine_bench_test.go (about) 1 package compiler 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/bananabytelabs/wazero/api" 8 "github.com/bananabytelabs/wazero/experimental" 9 "github.com/bananabytelabs/wazero/internal/wasm" 10 ) 11 12 func BenchmarkCallEngine_builtinFunctionFunctionListener(b *testing.B) { 13 f := &function{ 14 funcType: &wasm.FunctionType{ParamNumInUint64: 3}, 15 parent: &compiledFunction{ 16 listener: mockListener{ 17 before: func(context.Context, api.Module, api.FunctionDefinition, []uint64, experimental.StackIterator) { 18 }, 19 after: func(context.Context, api.Module, api.FunctionDefinition, []uint64) { 20 }, 21 }, 22 index: 0, 23 parent: &compiledCode{ 24 source: &wasm.Module{ 25 TypeSection: []wasm.FunctionType{{}}, 26 FunctionSection: []wasm.Index{0}, 27 CodeSection: []wasm.Code{{Body: []byte{wasm.OpcodeEnd}}}, 28 }, 29 }, 30 }, 31 } 32 33 ce := &callEngine{ 34 stack: []uint64{0, 1, 2, 3, 4, 0, 0, 0}, 35 stackContext: stackContext{stackBasePointerInBytes: 16}, 36 } 37 38 mod := new(wasm.ModuleInstance) 39 ctx := context.Background() 40 41 for i := 0; i < b.N; i++ { 42 ce.builtinFunctionFunctionListenerBefore(ctx, mod, f) 43 ce.builtinFunctionFunctionListenerAfter(ctx, mod, f) 44 } 45 }