mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-02 22:10:26 +08:00
29 lines
485 B
Go
29 lines
485 B
Go
package nodes
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/shirou/gopsutil/v3/cpu"
|
|
)
|
|
|
|
func TestNodeStatusExecutor_CPU(t *testing.T) {
|
|
countLogicCPU, err := cpu.Counts(true)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("logic count:", countLogicCPU)
|
|
|
|
countPhysicalCPU, err := cpu.Counts(false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("physical count:", countPhysicalCPU)
|
|
|
|
percents, err := cpu.Percent(100 * time.Millisecond, false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(percents)
|
|
}
|