You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-15 23:54:16 +02:00
examples
This commit is contained in:
3
examples/delve-trace/go.mod
Normal file
3
examples/delve-trace/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module github.com/felixge/go-profiler-notes/examples/delve-trace
|
||||
|
||||
go 1.16
|
24
examples/delve-trace/main.go
Normal file
24
examples/delve-trace/main.go
Normal 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
|
||||
}
|
13
examples/frame-order/frames.txt
Normal file
13
examples/frame-order/frames.txt
Normal 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
|
3
examples/frame-order/go.mod
Normal file
3
examples/frame-order/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module github.com/felixge/go-profiler-notes/examples/frame-order
|
||||
|
||||
go 1.15
|
21
examples/frame-order/main.go
Normal file
21
examples/frame-order/main.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user