gin/examples/realtime-advanced/stats.go

23 lines
504 B
Go
Raw Normal View History

2015-05-13 00:35:16 +00:00
package main
import (
"runtime"
"time"
)
func Stats() map[string]uint64 {
var stats runtime.MemStats
runtime.ReadMemStats(&stats)
return map[string]uint64{
"timestamp": uint64(time.Now().Unix()),
"HeapInuse": stats.HeapInuse,
"StackInuse": stats.StackInuse,
"NuGoroutines": uint64(runtime.NumGoroutine()),
2015-05-13 14:44:44 +00:00
"Mallocs": stats.Mallocs,
"Frees": stats.Mallocs,
"Inbound": uint64(messages.Get("inbound")),
"Outbound": uint64(messages.Get("outbound")),
2015-05-13 00:35:16 +00:00
}
}