Golang Pprof Detailed

Source: Internet
Author: User

Go's Pprof Pack

Go has pprof packages for code performance monitoring in two places with packages:

Net/http/pprof

Runtime/pprof

In fact, net/http/pprof only use the RUNTIME/PPROF package to encapsulate a bit, and exposed on the HTTP port.

This article only tells you how to view performance on the web.

First, the code part

1.import Add Net/http/pprof Pack

Import (    _ net/http/pprof)

2. Open the HTTP listening port

go func () {        log. Println (http. Listenandserve ("localhost:10000", Nil)} ()

Second, the page to view

* Browser can open http://127.0.0.1:10000/debug/pprof/to view various profile indexes

1. If you have installed Graphviz directly submitted this step, otherwise you can download to http://www.graphviz.org/download/, and add the bin to the environment variable

2. View Profile: Input at the command line

Go Tool pprof Http://localhost:10000/debug/pprof/profile

The following 30 seconds enter the status of the collection profile information.

Enter Pprof interactive mode after 30 seconds, then enter

Web

Then the browser automatically bounces to the Web page to display the SVG diagram

3. View the profile file that has been saved

Go Tool pprof Profile C:\Users\user\pprof\pprof.samples.cpu.004.pb.gz

Then it is also the interactive mode to enter Pprof, then enter the Web

You can also view the heap and Goroutine

  

Related Article

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.