Print memory usage in both bytes and megabytes
This commit is contained in:
parent
e1684fc8c0
commit
5ca2abb8d0
6
utils.go
6
utils.go
@ -6,6 +6,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const MEGABYTE = 1024 * 1024
|
||||
|
||||
func startRuntimeProfiler() {
|
||||
m := &runtime.MemStats{}
|
||||
|
||||
@ -14,8 +16,8 @@ func startRuntimeProfiler() {
|
||||
|
||||
fmt.Println("-----------------------")
|
||||
fmt.Println("Goroutines:", runtime.NumGoroutine())
|
||||
fmt.Println("Memory acquired:", m.Sys)
|
||||
fmt.Println("Memory used:", m.Alloc)
|
||||
fmt.Println("Memory acquired:", m.Sys, "bytes,", m.Sys/MEGABYTE, "mb")
|
||||
fmt.Println("Memory used:", m.Alloc, "bytes,", m.Alloc/MEGABYTE, "mb")
|
||||
|
||||
time.Sleep(time.Minute)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user