diff --git a/profilers/cpu.go b/profilers/cpu.go new file mode 100644 index 0000000..85eb79d --- /dev/null +++ b/profilers/cpu.go @@ -0,0 +1,18 @@ +package profilers + +import ( + "os" + "runtime/pprof" +) + +func GetCPUProfiler() func() { + f, err := os.Create("cpu.prof") + if err != nil { + panic(err) + } + if err := pprof.StartCPUProfile(f); err != nil { + panic(err) + } + return pprof.StopCPUProfile + +}