Created
May 18, 2020 08:30
-
-
Save xiegeo/d9f12ce4cc33c16b554d861c2ce4eeee to your computer and use it in GitHub Desktop.
turn on go pprof with a compiler flag/tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build pprof | |
// run `GODEBUG=gctrace=1,scavtrace=1 go test -bench=.* -benchmem -benchtime=1m -tags pprof` to prof benchmarks | |
package packagename | |
import ( | |
"fmt" | |
"net/http" | |
_ "net/http/pprof" | |
"runtime" | |
"time" | |
) | |
func init() { | |
go http.ListenAndServe("localhost:8080", nil) | |
go func() { | |
for { | |
time.Sleep(time.Second) | |
runtime.GC() | |
fmt.Println(time.Now()) | |
} | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment