MCPcopy Create free account
hub / github.com/CPChain/chain / StartCPUProfile

Method StartCPUProfile

internal/debug/api.go:80–98  ·  view source on GitHub ↗

StartCPUProfile turns on CPU profiling, writing to the given file.

(file string)

Source from the content-addressed store, hash-verified

78
79// StartCPUProfile turns on CPU profiling, writing to the given file.
80func (h *HandlerT) StartCPUProfile(file string) error {
81 h.mu.Lock()
82 defer h.mu.Unlock()
83 if h.cpuW != nil {
84 return errors.New("CPU profiling already in progress")
85 }
86 f, err := os.Create(expandHome(file))
87 if err != nil {
88 return err
89 }
90 if err := pprof.StartCPUProfile(f); err != nil {
91 f.Close()
92 return err
93 }
94 h.cpuW = f
95 h.cpuFile = file
96 log.Info("CPU profiling started", "dump", h.cpuFile)
97 return nil
98}
99
100// StopCPUProfile stops an ongoing CPU profile.
101func (h *HandlerT) StopCPUProfile() error {

Callers 2

CpuProfileMethod · 0.95
SetupFunction · 0.45

Calls 6

expandHomeFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected