StartProfile begins recording the CPU profile. The method returns a boolean to indicate whether starting the profile succeeded (e.g. false is returned if it was already started).
()
| 70 | // to indicate whether starting the profile succeeded (e.g. false is returned if |
| 71 | // it was already started). |
| 72 | func (p *CPUProfiler) StartProfile() bool { |
| 73 | p.mutex.Lock() |
| 74 | defer p.mutex.Unlock() |
| 75 | |
| 76 | if p.counts != nil { |
| 77 | return false // already started |
| 78 | } |
| 79 | |
| 80 | p.counts = make(stackCounterMap) |
| 81 | p.start = time.Now() |
| 82 | return true |
| 83 | } |
| 84 | |
| 85 | // StopProfile stops recording and returns the CPU profile. The method returns |
| 86 | // nil if recording of the CPU profile wasn't started. |
no outgoing calls