Currently, phase profiling runs GC at the end of a phase before
stopping the CPU profile. Rearrange things so we stop the CPU profile
right when we collect the end time-stamp and before dealing with GCs
and heap profiles.
Change-Id: I9a84b9b17c7db7f8cacf591147de15464298b6af
Reviewed-on: https://go-review.googlesource.com/c/go/+/224620
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
return
}
m.curMark.endT = time.Now()
- runtime.ReadMemStats(&m.curMark.endM)
- if m.gc == GC {
- runtime.GC()
- runtime.ReadMemStats(&m.curMark.gcM)
- }
if m.shouldPProf() {
pprof.StopCPUProfile()
m.pprofFile.Close()
m.pprofFile = nil
- if m.gc == GC {
+ }
+ runtime.ReadMemStats(&m.curMark.endM)
+ if m.gc == GC {
+ runtime.GC()
+ runtime.ReadMemStats(&m.curMark.gcM)
+ if m.shouldPProf() {
// Collect a profile of the live heap. Do a
// second GC to force sweep completion so we
// get a complete snapshot of the live heap at