1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-12-23 04:36:49 +00:00
cchat-gtk/profile.go
2020-08-20 16:53:13 -07:00

52 lines
967 B
Go

// +build prof
package main
import (
_ "net/http/pprof"
_ "github.com/ianlancetaylor/cgosymbolizer"
)
import "C"
const ProfileAddr = "localhost:49583"
func init() {
C.HeapProfilerStart()
destructor = func() { C.HeapProfilerStop() }
// runtime.SetBlockProfileRate(1)
// go func() {
// 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()
// }
// f, _ := os.Create("/tmp/cchat.pprof")
// if err := pprof.StartCPUProfile(f); err != nil {
// panic(err)
// }
// destructor = func() {
// pprof.StopCPUProfile()
// f.Close()
// }
}