mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 20:17:17 +00:00
22 lines
562 B
Go
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
|
||
|
}
|