package stats import ( "testing" "time" ) func TestNewStats(t *testing.T) { dura := 1 * time.Second rateRange := 1 * time.Second stats := NewStats(-1, dura, rateRange) err := stats.TryCgroupPath() if err != nil { t.Fatal(err) } for i := 1; i <= 2; i++ { memoryUsage, err := stats.GetMemoryWorkingSet() if err != nil { t.Fatal(err) } t.Log(i, "memory usage", memoryUsage) cpuUsage, err := stats.GetCPUUsage() if err != nil { t.Fatal(err) } t.Log(i, "cpu usage", cpuUsage) ioUsage, err := stats.GetIOUsage() if err != nil { t.Fatal(err) } t.Log(i, "io usage", ioUsage) time.Sleep(time.Second) } }