github.com/TeaOSLab/EdgeNode@v1.3.8/internal/nodes/node_status_executor_test.go (about)

     1  package nodes
     2  
     3  import (
     4  	"github.com/shirou/gopsutil/v3/cpu"
     5  	"testing"
     6  	"time"
     7  )
     8  
     9  func TestNodeStatusExecutor_CPU(t *testing.T) {
    10  	countLogicCPU, err := cpu.Counts(true)
    11  	if err != nil {
    12  		t.Fatal(err)
    13  	}
    14  	t.Log("logic count:", countLogicCPU)
    15  
    16  	countPhysicalCPU, err := cpu.Counts(false)
    17  	if err != nil {
    18  		t.Fatal(err)
    19  	}
    20  	t.Log("physical count:", countPhysicalCPU)
    21  
    22  	percents, err := cpu.Percent(100*time.Millisecond, false)
    23  	if err != nil {
    24  		t.Fatal(err)
    25  	}
    26  	t.Log(percents)
    27  }