Golang性能调节-通过net/http/pprof

Comments(5)


Posted on 2014-06-08 12:43:50 golang


Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool. For more information about pprof, see http://code.google.com/p/google-perftools/.

The package is typically only imported for the side effect of registering its HTTP handlers. The handled paths all begin with /debug/pprof/.

To use pprof, link this package into your program:

import _ "net/http/pprof"

If your application is not already running an http server, you need to start one. Add “net/http” and “log” to your imports and the following code to your main function:

go func() {
    log.Println(http.ListenAndServe("localhost:6060", nil))
}()

Then use the pprof tool to look at the heap profile:

go tool pprof http://localhost:6060/debug/pprof/heap

Or to look at a 30-second CPU profile:

go tool pprof http://localhost:6060/debug/pprof/profile

Or to look at the goroutine blocking profile:

go tool pprof http://localhost:6060/debug/pprof/block

To view all available profiles, open http://localhost:6060/debug/pprof/ in your browser.

For a study of the facility in action, visit

http://blog.golang.org/2011/06/profiling-go-programs.html

前一篇: 理解HTTP幂等性 后一篇: 两张图看懂GDT、GDTR、LDT、LDTR的关系

Captcha:
验证码

Email:

Content: (Support Markdown Syntax)


Propecia  2021-08-30 23:40:09 From 127.0.0.1

Triameterene For Sale


jeonirm  2022-01-06 03:50:17 From 127.0.0.1

cialis en ligne generic 5 mg cialis order cialis online dreampharmaceuticalscom


prayeni  2023-01-28 14:29:18 From 127.0.0.1

how much is clomid A number of positive 164 cfu ml microbial molecules sharing a bed with a complaint of ed


blareenda  2023-02-01 00:42:43 From 127.0.0.1

He was chatting on phone with many friends and family because no visitors allowed cialis 20mg price


ImmogsTob  2023-02-06 19:53:10 From 127.0.0.1

Irish healthcare spending in 2010 accounted for 9 generic cialis online