Files
netmaker/logic/proc.go
2024-11-07 18:18:08 +04:00

24 lines
442 B
Go

package logic
import (
"log"
"os"
"runtime/pprof"
)
func StartCPUProfiling() *os.File {
f, err := os.OpenFile("/root/data/cpu.prof", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0755)
if err != nil {
log.Fatal("could not create CPU profile: ", err)
}
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatal("could not start CPU profile: ", err)
}
return f
}
func StopCPUProfiling(f *os.File) {
pprof.StopCPUProfile()
f.Close()
}