Go profiling related

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. First, official documents
Https://blog.golang.org/profiling-go-programs

$CD Your_programe_dir
$go Build
$./your_programe-cpuprofile=xxx.prof
$go tool pprof./your_programe xxx.prof
Entering interactive mode (type ' help ' for commands)
(pprof) Top 10
...

(pprof) Web generates an SVG file and opens

Note: Mac is opened by default with sublime and needs to be modified to chrome:http://blog.csdn.net/jiaolongdy/article/details/50945684



1. If a prompt appears:
Cannot find dot, are you installed Graphviz?


Need to install Graphviz with root user
$sudo Brew Install Graphviz


2. If a prompt appears:
Profile is empty


That's because the default pprof sampling frequency is 100 times per second, which can happen if your program runs too fast and ends before the first sample.
Either add a For loop or sleep in the program, or adjust the sampling frequency (see two)


Two
At first, someone wrote a package that could be customized profiing:
Https://github.com/davecheney/profile


However, it was later updated with the following specific reasons:
http://dave.cheney.net/2014/10/22/simple-profiling-package-moved-updated


Because some projects already use the old API, the author gives a new package directly:
Https://github.com/pkg/profile

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.