MCPcopy
hub / github.com/helm/helm / startProfiling

Function startProfiling

pkg/cmd/profiling.go:41–55  ·  view source on GitHub ↗

startProfiling starts profiling CPU usage if HELM_PPROF_CPU_PROFILE is set to a file path. It returns an error if the file could not be created or CPU profiling could not be started.

()

Source from the content-addressed store, hash-verified

39// to a file path. It returns an error if the file could not be created or
40// CPU profiling could not be started.
41func startProfiling() error {
42 if cpuProfilePath != "" {
43 var err error
44 cpuProfileFile, err = os.Create(cpuProfilePath)
45 if err != nil {
46 return fmt.Errorf("could not create CPU profile: %w", err)
47 }
48 if err := pprof.StartCPUProfile(cpuProfileFile); err != nil {
49 cpuProfileFile.Close()
50 cpuProfileFile = nil
51 return fmt.Errorf("could not start CPU profile: %w", err)
52 }
53 }
54 return nil
55}
56
57// stopProfiling stops profiling CPU and memory usage.
58// It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE

Callers 1

newRootCmdWithConfigFunction · 0.85

Calls 2

CloseMethod · 0.80
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…