mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
fix gcstats debugging command
This commit is contained in:
parent
f32df20a83
commit
21a86c3216
@ -654,9 +654,11 @@ func (msg *DebugCommand) HandleServer(server *Server) {
|
|||||||
server.Reply(client, "OK")
|
server.Reply(client, "OK")
|
||||||
|
|
||||||
case "GCSTATS":
|
case "GCSTATS":
|
||||||
stats := &debug.GCStats{
|
stats := debug.GCStats{
|
||||||
|
Pause: make([]time.Duration, 10),
|
||||||
PauseQuantiles: make([]time.Duration, 5),
|
PauseQuantiles: make([]time.Duration, 5),
|
||||||
}
|
}
|
||||||
|
debug.ReadGCStats(&stats)
|
||||||
server.Reply(client, "last GC: %s", stats.LastGC.Format(time.RFC1123))
|
server.Reply(client, "last GC: %s", stats.LastGC.Format(time.RFC1123))
|
||||||
server.Reply(client, "num GC: %d", stats.NumGC)
|
server.Reply(client, "num GC: %d", stats.NumGC)
|
||||||
server.Reply(client, "pause total: %s", stats.PauseTotal)
|
server.Reply(client, "pause total: %s", stats.PauseTotal)
|
||||||
@ -671,14 +673,15 @@ func (msg *DebugCommand) HandleServer(server *Server) {
|
|||||||
server.Reply(client, "num goroutines: %d", count)
|
server.Reply(client, "num goroutines: %d", count)
|
||||||
|
|
||||||
case "PROFILEHEAP":
|
case "PROFILEHEAP":
|
||||||
file, err := os.Create("ergonomadic.heap.prof")
|
profFile := "ergonomadic-heap.prof"
|
||||||
|
file, err := os.Create(profFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error: %s", err)
|
log.Printf("error: %s", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
pprof.Lookup("heap").WriteTo(file, 0)
|
pprof.Lookup("heap").WriteTo(file, 0)
|
||||||
server.Reply(client, "written to ergonomadic-heap.prof")
|
server.Reply(client, "written to %s", profFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user