This is a creation in Article, where the information may have evolved or changed.
Reference:
Http://blog.golang.org/profiling-go-programs
Http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html
The pprof of the Go language is the porting of the Google C + + Profiler, so the usage is similar. Here is a summary record of the following steps:
1. Code
To turn on profiling in the go language, you can refer to the following code:
Import ("runtime/pprof"//reference PPROF package "OS") Func main () {f, _: = OS. Create ("Profile_file") pprof. Startcpuprofile (f) //Start CPU profile, and the results are written to file F defer pprof. Stopcpuprofile () //End profile ...}
2. Running
Run the program, generate the profile file
3. Analysis
Execute on the command line:
Go tool pprof [binary] [profile]
After entering the PPROF environment, you can use the Help command to view the information
The most commonly used commands, such as TOP10, can be viewed with the most time-consuming function
This explains in detail the output format of the top command, for example:
2.1% 17.2% 8.7% std::_rb_tree::find
The meanings of each field are:
1. Number of times the sample point falls in the function
2. Percentage of the sample point falling in the function
3. Cumulative percentage of the previous item
4. The total number of times the sample point falls in the function and the function it calls
5. percentage of total number of times the sample point falls in the function and the function it calls
6. Name of function