Created
July 9, 2020 01:14
-
-
Save leetrout/e46c67eccc54dadc732404e35cc54ca6 to your computer and use it in GitHub Desktop.
Quick drop in profiler snippet for Go
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
| // Rename your main func to _main and drop this in | |
| func main() { | |
| f, err := os.Create("trace_" + time.Now().Format("20060102150405")) | |
| if err != nil { | |
| panic(err) | |
| } | |
| trace.Start(f) | |
| _main() | |
| trace.Stop() | |
| f.Close() | |
| f, err = os.Create("memprof_" + time.Now().Format("20060102150405")) | |
| if err != nil { | |
| panic(err) | |
| } | |
| pprof.WriteHeapProfile(f) | |
| f.Close() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment