You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/pkg/stat/sys/cpu/cpu_test.go

23 lines
356 B

package cpu
import (
"fmt"
"testing"
"time"
)
func Test_CPUUsage(t *testing.T) {
var stat Stat
ReadStat(&stat)
fmt.Println(stat)
6 years ago
time.Sleep(time.Millisecond * 1000)
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)
}
}