github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/sigx/README.md (about) 1 # help 2 3 ## 代码嵌入 4 5 ```go 6 package main 7 8 import ( 9 "github.com/bingoohuang/gg/pkg/sigx" 10 ) 11 12 func init() { 13 sigx.RegisterSignalProfile() 14 } 15 ``` 16 17 ## cpu.profile 18 19 1. start to collect cpu.profile `touch jj.cpu; kill -USR1 69110` 20 2. after some time, like 10 minutes, repeat above cmd to stop. 21 3. `go tool pprof -http :9402 cpu.profile` to view 22 23 or 24 25 1. start to collect cpu.profile in 5m `echo 5m > jj.cpu; kill -USR1 69110` 26 1. after 5 minutes, `go tool pprof -http :9402 cpu.profile` to view 27 28 ## mem.profile 29 30 1. collect mem.profile `touch jj.mem; kill -USR1 6911` 31 1. `go tool pprof -http :9402 mem.profile` to view 32 33 ## jj.profile 34 35 1. collect specified `echo "cpu,heap,allocs,mutex,block,trace,threadcreate,goroutine,d:5m,rate:4096" > jj.profile` 36 2. `go tool pprof -http :9402 xx.pprof` or `go tool trace trace.out` to view