Skip to content

Instantly share code, notes, and snippets.

@snicol
Created December 5, 2017 15:35
Show Gist options
  • Save snicol/89908aafc3d02e24144d37205671a4af to your computer and use it in GitHub Desktop.
Save snicol/89908aafc3d02e24144d37205671a4af to your computer and use it in GitHub Desktop.
package main
import (
"runtime"
"fmt"
)
type SystemStat struct {
Alloc uint64
TotalAlloc uint64
HeapAlloc uint64
HeapSys uint64
NumCPU int
NumGoroutine int
GoVersion string
}
func main() {
mem := runtime.MemStats{}
runtime.ReadMemStats(&mem)
stat := SystemStat{
Alloc: mem.Alloc,
TotalAlloc: mem.TotalAlloc,
HeapAlloc: mem.HeapAlloc,
HeapSys: mem.HeapSys,
NumCPU: runtime.NumCPU(),
NumGoroutine: runtime.NumGoroutine(),
GoVersion: runtime.Version(),
}
fmt.Printf("%+v\n", stat)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment