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.
()
| 39 | // to a file path. It returns an error if the file could not be created or |
| 40 | // CPU profiling could not be started. |
| 41 | func 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 |
no test coverage detected
searching dependent graphs…