Go1.5 full version of the program performance analysis of small accumulation, experimental environment WINDOWS64

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Method One:

Use: Set godebug=gctrace=1/ godebug=gctrace=2

Run the executable directly: Server.exe

Format: GC # @ #s #%: #+...+# ms Clock, #+...+# MS CPU, #->#-># MB, # MB goal, # P

GC # indicates the first few GC

@ #s indicates how long the program started executing the GC

#% indicates the percentage of time that the program started GC elapsed (percentage of spent in GC since programs start)

The #+...+# represents the CPU blocking time during GC execution and

#->#-># MB indicates that the GC starts the heap size, ends the heap size, and the active heap size

# MB goal indicates target pair size

# P Indicates the number of CPU cores during program run

Example:

GC @1277.835s 0%: 0+1.0+0+1.0+1.0 ms Clock, 0+1.0+0+0/1.0/0+3.0 MS CPU, 0->0->0 MB, 4 MB goal, 4 P


Method Two:

Import _ "Net/http/pprof" Go func () {log. Println (http. Listenandserve ("localhost:6060", Nil)} () Add the above code to the program.-----------------------------------------------------------use the following command to view the performance: Go Tool pprof/HTTP Localhost:6060/debug/pprof/heap viewing CPU usage in 30 seconds: Go tool pprof http://localhost:6060/debug/pprof/ Profile View Goroutime performance: Go tool pprof Http://localhost:6060/debug/pprof/block view 5-second execution trace.wget http://localhost:6060/ Debug/pprof/trace?seconds=5 Open in Browser view: http://localhost:6060/debug/pprof/https://blog.golang.org/2011/06/ profiling-go-programs.html command: Go tool pprof/mnt/go/src/main http://localhost:6060/debug/pprof/ The heap input list can be seen in detail. Input web can be viewed on a Web page in addition we can also run Go tool pprof your-executable-name--dot profile-filename > HEAP.GV, this will get a HEAP.GV file, and we'll open this file in Graphviz to get a more detailed memory consumption graph that includes the call relationship. Of course, if we only need a picture, we can run Dot-tpng HEAP.GV > Heap.png Save this GV file as a PNG, so I can show the results below as I do.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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.