>From the top of my head, shouldn't the benchmark be done when traffic is being sent to the server and not before it is sent?
On Sunday, 26 November 2017 00:11:40 UTC+5:30, basti skalendudler wrote: > > Hey guiys, I posted a StackOF question two days ago, but so far nobody was > able to help me! > > I am trying to profile my web server I wrote, but my pprof does not > contain any data about the handler func. > I am using the httprouter package > <https://github.com/julienschmidt/httprouter> by julienschmidt, and want > to simply benchmark one of my handlers and see the pprof profile for that. > For the benchmarking, I am using go-wrk > <https://github.com/tsliwowicz/go-wrk> > > I set up my web server and pprof like this: > > > // Configure the server > server := &http.Server{ > Addr: ":4000", > Handler: router, > } > > > go func() { > log.Println(http.ListenAndServe(":6060", nil)) > }() > > > // Start the server > err = server.ListenAndServe() > if err != nil { > panic(err) > } > > > The router is initialized like this: > > > // Create the httprouter > router := httprouter.New() > // Register all handlers > router.GET("/entities/:type/map", h.UseHandler(&h. > ApiGetEntitiesMapRequest{}, p)) > > > And my handler looks like this: > > > func (req ApiGetEntitiesMapRequest) Handle(r *http.Request, hrp > httprouter.Params, p Params) (interface{}, error) { > test := make([]string, 0) > for i := 0; i < 1000; i++ { > test = append(test, "1") > test = append(test, "2") > // Ensure pprof has some time to collect its data > time.Sleep(10) > } > return test, nil > } > > This handler is just a test, where I dynamically append a lot of elements > to a slice. The reason for that is, I wanted to test whether these dynamic > allocations are represented in the heap profile of pprof. > > Now, what I did was: > > - Start my server > - execute **go tool pprof http://localhost:6060/debug/pprof/heap** in my > terminal > - then benchmark my handler by executing **go-wrk -no-c -d 5 > http://localhost:4000/entities/object/map** > > The request works and my benchmark also reports everything correctly. > However, when I type **png** in the pprof terminal, I get this graph: > > > <https://lh3.googleusercontent.com/-H5BlDsvkGc8/WhkpNlbAgBI/AAAAAAAABMQ/MagwiySh4F8G5NvT4V4_uTAnHexw0VqBACLcBGAs/s1600/profile001.png> > > > The graph does not contain any information about my handler and the costly > heap allocations I did in my handler. What am I doing wrong? > -- 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.