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

52 lines
967 B
Go
Raw Normal View History

// +build prof
package main
import (
_ "net/http/pprof"
_ "github.com/ianlancetaylor/cgosymbolizer"
)
2020-08-20 23:53:13 +00:00
import "C"
const ProfileAddr = "localhost:49583"
func init() {
2020-08-20 23:53:13 +00:00
C.HeapProfilerStart()
destructor = func() { C.HeapProfilerStop() }
// runtime.SetBlockProfileRate(1)
// go func() {
2020-08-20 23:53:13 +00:00
// log.Println("Listening to profiler at", ProfileAddr)
// if err := http.ListenAndServe(ProfileAddr, nil); err != nil {
// log.Error(errors.Wrap(err, "Failed to start profiling HTTP server"))
// }
// }()
// 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()
// }
2020-08-20 23:53:13 +00:00
// f, _ := os.Create("/tmp/cchat.pprof")
// if err := pprof.StartCPUProfile(f); err != nil {
// panic(err)
// }
2020-08-20 23:53:13 +00:00
// destructor = func() {
// pprof.StopCPUProfile()
// f.Close()
// }
}