Add profilers package
This commit is contained in:
parent
db9d9bcf44
commit
af491e27a0
18
profilers/cpu.go
Normal file
18
profilers/cpu.go
Normal file
|
@ -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
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user