mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add block profiling support
Updates #15756 Change-Id: Ic635812b324af926333122c02908cebfb24d7bce Reviewed-on: https://go-review.googlesource.com/39208 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
877574725b
commit
96af817497
3 changed files with 15 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ func Exit(code int) {
|
|||
}
|
||||
|
||||
var (
|
||||
blockprofile string
|
||||
cpuprofile string
|
||||
memprofile string
|
||||
memprofilerate int64
|
||||
|
|
@ -73,6 +74,17 @@ func startProfile() {
|
|||
// Not doing memory profiling; disable it entirely.
|
||||
runtime.MemProfileRate = 0
|
||||
}
|
||||
if blockprofile != "" {
|
||||
f, err := os.Create(blockprofile)
|
||||
if err != nil {
|
||||
Fatalf("%v", err)
|
||||
}
|
||||
runtime.SetBlockProfileRate(1)
|
||||
atExit(func() {
|
||||
pprof.Lookup("block").WriteTo(f, 0)
|
||||
f.Close()
|
||||
})
|
||||
}
|
||||
if traceprofile != "" && traceHandler != nil {
|
||||
traceHandler(traceprofile)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue