github.com/stealthrocket/wzprof@v0.2.1-0.20230830205924-5fa86be5e5b3/wzprof_test.go (about) 1 package wzprof 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/tetratelabs/wazero/api" 8 "github.com/tetratelabs/wazero/experimental" 9 "github.com/tetratelabs/wazero/experimental/wazerotest" 10 ) 11 12 func benchmarkFunctionListener(b *testing.B, factory experimental.FunctionListenerFactory) { 13 malloc := wazerotest.NewFunction(func(ctx context.Context, mod api.Module, size uint32) uint32 { 14 return 0 15 }) 16 17 malloc.FunctionName = "malloc" 18 malloc.ExportNames = []string{"malloc"} 19 20 module := wazerotest.NewModule(nil, 21 malloc, 22 ) 23 24 stack := []experimental.StackFrame{ 25 {Function: malloc, Params: []uint64{42}, Results: []uint64{0}}, 26 } 27 28 experimental.BenchmarkFunctionListener(b.N, module, stack, 29 factory.NewFunctionListener(malloc.Definition()), 30 ) 31 }