I have built a web server and did an ab(apache benchmark) test. Now I want to know the computing time of each part.
I used the go tool pprof url:port/xxx
and get the profile of this program, but it does not tell me the computing time(only has memory). Following is the results:
(pprof) top10
1827.59MB of 1978.12MB total (92.39%)
Dropped 175 nodes (cum <= 9.89MB)
Showing top 10 nodes out of 48 (cum >= 43.50MB)
flat flat% sum% cum cum%
769.54MB 38.90% 38.90% 769.54MB 38.90% reflect.unsafe_New
459.08MB 23.21% 62.11% 459.08MB 23.21% services/semanticnew.TopicProbCounter.Update
189.17MB 9.56% 71.67% 1081.21MB 54.66% github.com/golang/protobuf/proto.(*Buffer).dec_slice_struct
122MB 6.17% 77.84% 122MB 6.17% github.com/golang/protobuf/proto.(*Buffer).dec_int32
107.56MB 5.44% 83.28% 107.56MB 5.44% github.com/garyburd/redigo/redis.(*conn).readReply
68.13MB 3.44% 86.72% 527.21MB 26.65% services/semanticnew.caculApPoiScore
40.51MB 2.05% 88.77% 40.51MB 2.05% runtime.malg
28.59MB 1.45% 90.22% 28.59MB 1.45% net/http.newBufioWriterSize
22.50MB 1.14% 91.35% 23MB 1.16% redismanage.(*Manager).getRequest
20.50MB 1.04% 92.39% 43.50MB 2.20% redismanage.(*Manager).GetRequest
In my web program, I have added the following code:
f, _ := os.Create("x.cpuprofile")
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
but it still does not work.
I have checked http://blog.golang.org/profiling-go-programs, but the xxx.prof
file confused me. How can I generate this xxx.prof
file? And the author used go tool pprof xxx xxx.prof
, does it mean that xxx
is the binary file which generated by xxx.go
?
Anyway, the target is getting the computing time, but how? Do I have to generate this xxx.prof
file to achieve this goal?
Many thanks