1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-11-01 03:54:16 +00:00
cchat-gtk/profile.go

46 lines
793 B
Go

// +build prof
package main
import (
"os"
"runtime/pprof"
_ "net/http/pprof"
_ "github.com/ianlancetaylor/cgosymbolizer"
)
func init() {
// go func() {
// if err := http.ListenAndServe("localhost:42069", nil); err != nil {
// log.Error(errors.Wrap(err, "Failed to start profiling HTTP server"))
// }
// }()
// runtime.SetBlockProfileRate(1)
// f, _ := os.Create("/tmp/cchat.pprof")
// p := pprof.Lookup("block")
// destructor = func() {
// log.Println("==destructor==")
// if err := p.WriteTo(f, 2); err != nil {
// log.Println("Profile writeTo error:", err)
// }
// f.Close()
// }
f, _ := os.Create("/tmp/cchat.pprof")
if err := pprof.StartCPUProfile(f); err != nil {
panic(err)
}
destructor = func() {
pprof.StopCPUProfile()
f.Close()
}
}