1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-26 03:52:12 +02:00
kratos/pkg/stat/sys/cpu/cpu_test.go

23 lines
355 B
Go
Raw Normal View History

2019-06-17 15:43:35 +08:00
package cpu
import (
"fmt"
"testing"
"time"
)
func Test_CPUUsage(t *testing.T) {
var stat Stat
ReadStat(&stat)
fmt.Println(stat)
time.Sleep(time.Millisecond * 600)
for i := 0; i < 6; i++ {
time.Sleep(time.Millisecond * 500)
ReadStat(&stat)
if stat.Usage == 0 {
t.Fatalf("get cpu failed!cpu usage is zero!")
}
fmt.Println(stat)
}
}