gin/examples/realtime-advanced/stats.go

26 lines
576 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()),
//"Latency": latency,
"Mallocs": stats.Mallocs,
"Frees": stats.Mallocs,
// "HeapIdle": stats.HeapIdle,
// "HeapInuse": stats.HeapInuse,
// "HeapReleased": stats.HeapReleased,
// "HeapObjects": stats.HeapObjects,
}
}