mirror of https://github.com/golang/go.git
cmd/covdata: close cpu and mem profile
Change-Id: Iaf14989eb2981f724c4091f992ed99687ce3a60e
GitHub-Last-Rev: 6e6c82bb8f
GitHub-Pull-Request: golang/go#66852
Reviewed-on: https://go-review.googlesource.com/c/go/+/579255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
626f6db588
commit
f367fea83a
|
|
@ -176,7 +176,12 @@ func main() {
|
|||
if err := pprof.StartCPUProfile(f); err != nil {
|
||||
fatal("%v", err)
|
||||
}
|
||||
atExit(pprof.StopCPUProfile)
|
||||
atExit(func() {
|
||||
pprof.StopCPUProfile()
|
||||
if err = f.Close(); err != nil {
|
||||
fatal("error closing cpu profile: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
if *memprofileflag != "" {
|
||||
if *memprofilerateflag != 0 {
|
||||
|
|
@ -192,6 +197,9 @@ func main() {
|
|||
if err := pprof.Lookup("heap").WriteTo(f, writeLegacyFormat); err != nil {
|
||||
fatal("%v", err)
|
||||
}
|
||||
if err = f.Close(); err != nil {
|
||||
fatal("error closing memory profile: %v", err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Not doing memory profiling; disable it entirely.
|
||||
|
|
|
|||
Loading…
Reference in New Issue