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/psutilCPU_test.go

24 lines
440 B

package cpu
import (
"fmt"
"testing"
"time"
)
func Test_PsutilCPU(t *testing.T) {
cpu, err := newPsutilCPU(time.Millisecond * 500)
if err != nil {
t.Fatalf("newPsutilCPU failed!err:=%v", err)
}
6 years ago
time.Sleep(time.Millisecond * 600)
for i := 0; i < 6; i++ {
6 years ago
time.Sleep(time.Millisecond * 600)
u, err := cpu.Usage()
if u == 0 {
t.Fatalf("get cpu from psutil failed!cpu usage is zero!err:=%v", err)
}
fmt.Println(u)
}
}