"tools/vbios_check.sh" did not exist on "ffeec139c133db845cf26337230658320f41736f"
system_test.go 865 Bytes
Newer Older
liming6's avatar
liming6 committed
1
2
3
4
package utils

import (
	"testing"
liming6's avatar
liming6 committed
5
6
7
	"time"

	"github.com/shirou/gopsutil/v4/cpu"
8
	"github.com/shirou/gopsutil/v4/process"
liming6's avatar
liming6 committed
9
10
11
12
13
14
15
16
17
)

func TestGetSysUsers(t *testing.T) {
	a, e := cpu.Percent(0, false)
	if e != nil {
		t.Error(e)
	}
	t.Logf("%+v", a)
}
liming6's avatar
liming6 committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

func TestGetSysInfo(t *testing.T) {
	start := time.Now
	info, err := GetSysInfo()
	d := time.Since(start())
	if err != nil {
		t.Error(err)
	}
	t.Logf("%d: %+v", d.Nanoseconds(), *info)
}

func BenchmarkGetSysInfo(b *testing.B) {
	result := make([]float64, b.N)
	for i := 0; i < b.N; i++ {
		info, err := GetSysInfo()
		if err != nil {
			b.Error(err)
		}
		result[i] = info.CPUPercent
	}
	b.Logf("%+v", result)
}
40
41
42
43
44
45
46
47

func TestCPUTime(t *testing.T) {
	p, _ := process.NewProcess(1)
	tt, _ := p.Times()
	t.Logf("%s", tt.String())
	tt1 := time.Duration(int((tt.User + tt.System))) * time.Second
	t.Logf("%s", tt1.String())
}