Go Program Performance Analysis Pprof

Source: Internet
Author: User
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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.