Skip to content

Instantly share code, notes, and snippets.

Last active April 27, 2022 03:01
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Golang Flame graph profiles
#install FlameGraph library
cd /opt/
sudo git clone
#make it accesible from any folder
vim ~/.bashrc
##add these lines anywhere and exit vim (if you can)
export FLAMEPATH=/opt/FlameGraph
#Golang - go-torch pprof alternative for flame graphs profiles
go get
#install Graphviz (for go tool pprof export)
go get
sudo apt-get install graphviz #works in ubuntu, for others see
#if your benchmark is called: BenchmarkProcessThreadPool50()
#your package name (current folder) is called "AlfaGo"
#the followign command will generate 2 files: "AlfaGo.test" and "Thread50.gz"
go test -bench=ProcessThreadPool50 -cpuprofile=Thread50.gz
#rename the binary for posterity
mv AlfaGo.test Thread50.test
#generate a flamegraph svg
go-torch -f "Thread50Flame.svg" Thread50.test Thread50.gz
#generate a pprof svg graph
go tool pprof -svg -output "Thread50Graph.svg" hread50.test Thread50.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment