MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / StartProfile

Function StartProfile

utils/profiler.go:33–56  ·  view source on GitHub ↗

StartProfile initializes the CPU and memory profile, if specified.

(cpuprofile, memprofile string)

Source from the content-addressed store, hash-verified

31
32// StartProfile initializes the CPU and memory profile, if specified.
33func StartProfile(cpuprofile, memprofile string) error {
34 if cpuprofile != "" {
35 f, err := os.Create(cpuprofile)
36 if err != nil {
37 log.WithField("file", cpuprofile).WithError(err).Error("failed to create CPU profile file")
38 return err
39 }
40 log.WithField("file", cpuprofile).Info("writing CPU profiling to file")
41 prof.cpu = f
42 pprof.StartCPUProfile(prof.cpu)
43 }
44
45 if memprofile != "" {
46 f, err := os.Create(memprofile)
47 if err != nil {
48 log.WithField("file", memprofile).WithError(err).Error("failed to create memory profile file")
49 return err
50 }
51 log.WithField("file", memprofile).WithError(err).Info("writing memory profiling to file")
52 prof.mem = f
53 runtime.MemProfileRate = 4096
54 }
55 return nil
56}
57
58// StopProfile closes the CPU and memory profiles if they are running.
59func StopProfile() {

Callers 3

mainFunction · 0.92
mainFunction · 0.92
TestStartStopProfileFunction · 0.85

Calls 5

WithFieldFunction · 0.92
ErrorMethod · 0.80
WithErrorMethod · 0.80
InfoMethod · 0.80
CreateMethod · 0.65

Tested by 1

TestStartStopProfileFunction · 0.68