mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
28 lines
482 B
Go
28 lines
482 B
Go
package nodes
|
|
|
|
import (
|
|
"github.com/shirou/gopsutil/v3/cpu"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
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)
|
|
}
|