github.com/stealthrocket/wzprof@v0.2.1-0.20230830205924-5fa86be5e5b3/testdata/go/simple.go (about) 1 package main 2 3 import "fmt" 4 import "runtime" 5 6 //go:noinline 7 func thealloc() []byte { 8 pcs := make([]uintptr, 100) 9 n := runtime.Callers(0, pcs) 10 pcs = pcs[:n] 11 12 for _, pc := range pcs { 13 fmt.Println("-", pc) 14 } 15 16 return make([]byte, 11111) 17 } 18 19 //go:noinline 20 func myfunc() int { 21 x := thealloc() 22 for i := range x { 23 x[i] = byte(i) 24 } 25 total := 0 26 for _, i := range x { 27 total += int(i) 28 } 29 return total 30 } 31 32 func main() { 33 fmt.Println("this is my program") 34 35 x := myfunc() 36 37 // x := myOtherFunc(10000) 38 39 fmt.Println("final length:", x) 40 }