The net/pprof package works great for this. What do you get when you run
one of these?

go tool pprof http://localhost:6060/debug/pprof/profile

or

go tool pprof http://localhost:6060/debug/pprof/heap

You may have to replace port 6060 with the port you're actually listening
on. Once you're in there you can type "web" to get a graphic showing where
your CPU is being used.

If that's not working, perhaps you're capturing the /debug path with one of
your handlers. I recommend running a separate server on port 6060 that only
listens on localhost (for security reasons). Also, you should create a
separate http.Server instance for this. If you're using the default
http.Server in your code, you won't want to mix them, otherwise you could
run into the same collision problem. Plus, you never want your profile info
to be available to the public anyway.

Maybe something like this that you run in a gorouine in your main()
function:


func serveProfiler() {

    mux := http.NewServeMux()
    profServer := http.Server{
        Addr:         ":6060",
        Handler:      mux,
    }

    log.Fatalf("failed to start profile server\n",
profServer.ListenAndServe())
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to