stat/stat.go

27 lines
409 B
Go

package stat
import "runtime"
type Profile struct {
Alloc uint64
TotalAlloc uint64
SysMem uint64
NumGC uint32
}
func GetProfile() *Profile {
var m runtime.MemStats
runtime.ReadMemStats(&m)
return &Profile{
Alloc: bToMb(m.Alloc),
TotalAlloc: bToMb(m.TotalAlloc),
SysMem: bToMb(m.Sys),
NumGC: m.NumGC,
}
}
func bToMb(b uint64) uint64 {
return b / 1024 / 1024
}