= Profiling in Golang =
Is it time to check why your code is so slow?
Install pprof handlers automatically:
|
|
Run the app, and then:
❯ go tool pprof 'http://localhost:6060/debug/pprof/profile?seconds=60'
Fetching profile over HTTP from http://localhost:6060/debug/pprof/profile?seconds=60
Saved profile in /Users/bx2/pprof/pprof.main.samples.cpu.001.pb.gz
File: main
Type: cpu
Time: Mar 19, 2024 at 8:14pm (CET)
Duration: 60.08s, Total samples = 3.79s ( 6.31%)
Entering interactive mode (type "help" for commands, "o" for options)
Then:
(pprof) web
This will load and open your browser with a visualization allowing you to look reason about the generated profile.
Additionally, if you want to look at pprof information, open this url
http://localhost:6060/debug/pprof/heap?debug=1
in your browser.