1
0
mirror of https://github.com/DataDog/go-profiler-notes.git synced 2025-07-15 23:54:16 +02:00
This commit is contained in:
Felix Geisendörfer
2021-05-24 11:50:26 +02:00
parent 7a7b1562e9
commit ca63f541c3
5 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,3 @@
module github.com/felixge/go-profiler-notes/examples/delve-trace
go 1.16

View File

@ -0,0 +1,24 @@
package main
import (
"fmt"
"os"
)
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run() error {
for i := 0; i < 10; i++ {
foo(i)
}
return nil
}
func foo(i int) int {
return i * 2
}

View File

@ -0,0 +1,13 @@
goroutine 1 [running]:
runtime/pprof.writeGoroutineStacks(0x111e660, 0xc0000a0018, 0x30, 0x12b3aa8)
/usr/local/Cellar/go/1.15.7_1/libexec/src/runtime/pprof/pprof.go:693 +0x9f
runtime/pprof.writeGoroutine(0x111e660, 0xc0000a0018, 0x2, 0x0, 0x602e6537)
/usr/local/Cellar/go/1.15.7_1/libexec/src/runtime/pprof/pprof.go:682 +0x45
runtime/pprof.(*Profile).WriteTo(0x11ae4e0, 0x111e660, 0xc0000a0018, 0x2, 0xc0000a0020, 0x0)
/usr/local/Cellar/go/1.15.7_1/libexec/src/runtime/pprof/pprof.go:331 +0x3f2
main.bar()
/Users/felix.geisendoerfer/go/src/github.com/felixge/go-profiler-notes/examples/frame-order/main.go:19 +0xd5
main.foo(...)
/Users/felix.geisendoerfer/go/src/github.com/felixge/go-profiler-notes/examples/frame-order/main.go:13
main.main()
/Users/felix.geisendoerfer/go/src/github.com/felixge/go-profiler-notes/examples/frame-order/main.go:9 +0x25

View File

@ -0,0 +1,3 @@
module github.com/felixge/go-profiler-notes/examples/frame-order
go 1.15

View File

@ -0,0 +1,21 @@
package main
import (
"os"
"runtime/pprof"
)
func main() {
foo()
}
func foo() {
bar()
}
func bar() {
debug2, _ := os.Create("frames.txt")
debug0, _ := os.Create("frames.pb.gz")
pprof.Lookup("goroutine").WriteTo(debug2, 2)
pprof.Lookup("goroutine").WriteTo(debug0, 0)
}