stats.go 576 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "runtime"
  4. "time"
  5. )
  6. func Stats() map[string]uint64 {
  7. var stats runtime.MemStats
  8. runtime.ReadMemStats(&stats)
  9. return map[string]uint64{
  10. "timestamp": uint64(time.Now().Unix()),
  11. "HeapInuse": stats.HeapInuse,
  12. "StackInuse": stats.StackInuse,
  13. "NuGoroutines": uint64(runtime.NumGoroutine()),
  14. //"Latency": latency,
  15. "Mallocs": stats.Mallocs,
  16. "Frees": stats.Mallocs,
  17. // "HeapIdle": stats.HeapIdle,
  18. // "HeapInuse": stats.HeapInuse,
  19. // "HeapReleased": stats.HeapReleased,
  20. // "HeapObjects": stats.HeapObjects,
  21. }
  22. }