daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "runtime"
  5.     "fmt"
  6.    
  7. )
  8. type SystemStat struct {
  9.     Alloc        uint64
  10.     TotalAlloc   uint64
  11.     HeapAlloc    uint64
  12.     HeapSys      uint64
  13.     NumCPU       int
  14.     NumGoroutine int
  15.     GoVersion    string
  16. }
  17.    
  18. func main() {
  19.     mem := runtime.MemStats{}
  20.     runtime.ReadMemStats(&mem)
  21.  
  22.     stat := SystemStat{
  23.         Alloc:        mem.Alloc,
  24.         TotalAlloc:   mem.TotalAlloc,
  25.         HeapAlloc:    mem.HeapAlloc,
  26.         HeapSys:      mem.HeapSys,
  27.         NumCPU:       runtime.NumCPU(),
  28.         NumGoroutine: runtime.NumGoroutine(),
  29.         GoVersion:    runtime.Version(),
  30.     }
  31.  
  32.     fmt.Printf("%+v\n", stat)
  33. }
RAW Paste Data
Top