Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Last active June 4, 2024 23:21
Show Gist options
  • Save pojntfx/389c52d06086b89d417dd8558b69b063 to your computer and use it in GitHub Desktop.
Save pojntfx/389c52d06086b89d417dd8558b69b063 to your computer and use it in GitHub Desktop.
Use `pprof` to profile a Go application
import _ "net/http/pprof"
// ...
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
#!/bin/bash
# CPU:
go tool pprof -http=localhost:8080 localhost:6060 # Will collect samples for ~10s
# Memory:
go tool pprof -http=localhost:8080 localhost:6060/debug/pprof/heap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment