For profing program I use the following command:
go tool pprof http://localhost:6060/debug/pprof/profile
As a result in web mode I get this picture:
How is it possible to show the number of function calls, not the time spent inside of this function like on the same pictures from golang blog?
P.S There is a similar question. But how to do it only with pprof (without kcachegrind and other tools)?
In the go tool pprof output, there is a row for each function that appeared in a sample. The first two columns show the number of samples in which the function was running (as opposed to waiting for a called function to return), as a raw count and as a percentage of total samples.
pprof is a tool for visualization and analysis of profiling data. analyze the data. It can generate both text and graphical reports (through the use of the dot visualization package). First, we need to add monitoring code in the golang program, and expose it through the http interface.
To do the profiling, we can call the /debug/pprof/profile and specify how long it will run in the seconds parameter, then save the result in a file. This is the command for that using curl: Wait until the profiling finish and then we can analyze the result. Now that we have the pprof file, we can analyze it using go tool pprof.
When using golang to write complex projects, it is often useful to use multi-coroutine concurrency scenarios. At this time, it is easy to cause the problem of coroutine leaks due to negligence, and then produce similar memory leaks. This program memory. pprof is a tool for visualization and analysis of profiling data. analyze the data.
Golang's profiling works by calculating function appear count in stacks, once per sample time window. It doesnot get calls and calleds, but rather get seen calls and seens calleds. So in fact it can't give call count, but can give time spending which is different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With