37 lines
No EOL
689 B
Go
37 lines
No EOL
689 B
Go
package profiling
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"github.com/gorilla/mux"
|
|
_ "net/http/pprof"
|
|
)
|
|
|
|
func Profile() {
|
|
go func() {
|
|
router := mux.NewRouter()
|
|
router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
|
|
log.Println("Starting profiler...")
|
|
if err := http.ListenAndServe(":6060", router); err != nil {
|
|
panic(err)
|
|
}
|
|
}()
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
docker run -p 6060:6060 -e REQUIRED_ENV=http://value -e ANOTHER_ENV=anothervalue workername
|
|
|
|
THEN
|
|
go tool pprof http://localhost:6060/debug/pprof/heap
|
|
OR
|
|
go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
|
|
|
|
(Look up https://golang.org/pkg/net/http/pprof/)
|
|
|
|
|
|
THEN
|
|
https://www.speedscope.app/
|
|
|
|
*/ |