2014-11-21 05:00:45 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2014-11-21 06:00:53 +03:00
|
|
|
const MEGABYTE = 1024 * 1024
|
|
|
|
|
2014-11-21 05:00:45 +03:00
|
|
|
func startRuntimeProfiler() {
|
|
|
|
m := &runtime.MemStats{}
|
|
|
|
|
|
|
|
for {
|
|
|
|
runtime.ReadMemStats(m)
|
|
|
|
|
|
|
|
fmt.Println("-----------------------")
|
|
|
|
fmt.Println("Goroutines:", runtime.NumGoroutine())
|
2014-11-21 06:00:53 +03:00
|
|
|
fmt.Println("Memory acquired:", m.Sys, "bytes,", m.Sys/MEGABYTE, "mb")
|
|
|
|
fmt.Println("Memory used:", m.Alloc, "bytes,", m.Alloc/MEGABYTE, "mb")
|
2014-11-21 05:00:45 +03:00
|
|
|
|
2014-11-22 02:20:30 +03:00
|
|
|
time.Sleep(time.Second * 30)
|
2014-11-21 05:00:45 +03:00
|
|
|
}
|
|
|
|
}
|