erigon-pulse/common/debug/memstats.go
Alex Sharov fc7291ec34
Use local db in analytics (#308)
* Use local db in analytics (#308)
* pool of encoders
* incr and decr funcs
2020-01-15 19:47:13 +07:00

22 lines
562 B
Go

package debug
import (
"fmt"
"runtime"
)
func PrintMemStats(short bool) {
var m runtime.MemStats
runtime.ReadMemStats(&m)
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
if short {
fmt.Printf("HeapInuse: %vMb\n", ByteToMb(m.HeapInuse))
} else {
fmt.Printf("HeapInuse: %vMb, Alloc: %vMb, TotalAlloc: %vMb, Sys: %vMb, NumGC: %v, PauseNs: %d\n", ByteToMb(m.HeapInuse), ByteToMb(m.Alloc), ByteToMb(m.TotalAlloc), ByteToMb(m.Sys), m.NumGC, m.PauseNs[(m.NumGC+255)%256])
}
}
func ByteToMb(b uint64) uint64 {
return b / 1024 / 1024
}