I'm doing Go training in my company and I want to present in best way pprof package. I think that My example isn't good enough to simply present power of pprof. I want to use only go std library. Code should give me simplier call graph with some bottleneck.
My current workflow is as below: 1. include pprof in webserver 2. run webserver (it'll gather data for 30 seconds (default)) 3. run some curl shots to webserver 4. present pprof graphs
My code looks like below:
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
)
func handler(w http.ResponseWriter, r *http.Request) {
for i := 0; i < 100000000; i++ {
w.Write([]byte(fmt.Sprintf("%d - %d, ", i, i)))
}
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}