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

Method StartCPUProfile

internal/profile/handler.go:58–76  ·  view source on GitHub ↗

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

(file string)

Source from the content-addressed store, hash-verified

56
57// StartCPUProfile turns on CPU profiling, writing to the given file.
58func (h *HandlerT) StartCPUProfile(file string) error {
59 h.mu.Lock()
60 defer h.mu.Unlock()
61 if h.cpuW != nil {
62 return errors.New("CPU profiling already in progress")
63 }
64 f, err := os.Create(file)
65 if err != nil {
66 return err
67 }
68 if err := pprof.StartCPUProfile(f); err != nil {
69 f.Close()
70 return err
71 }
72 h.cpuW = f
73 h.cpuFile = file
74 log.Info("CPU profiling started", "dump", h.cpuFile)
75 return nil
76}
77
78// StopCPUProfile stops an ongoing CPU profile.
79func (h *HandlerT) StopCPUProfile() error {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected