2024-06-04 18:19:17 +02:00
|
|
|
package profilers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime/pprof"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetCPUProfiler() func() {
|
|
|
|
f, err := os.Create("cpu.prof")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2024-06-09 06:58:10 +02:00
|
|
|
defer f.Close()
|
2024-06-04 18:19:17 +02:00
|
|
|
if err := pprof.StartCPUProfile(f); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return pprof.StopCPUProfile
|
|
|
|
}
|