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.
23 lines
355 B
23 lines
355 B
5 years ago
|
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)
|
||
|
}
|
||
|
}
|