embed frontend

This commit is contained in:
0xJacky 2022-02-18 00:01:27 +08:00
parent 882fe8c074
commit d09f484790
86 changed files with 884 additions and 12326 deletions

36
test/analytic_test.go Normal file
View file

@ -0,0 +1,36 @@
package test
import (
"fmt"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/load"
"github.com/shirou/gopsutil/v3/mem"
"runtime"
"testing"
"time"
)
func TestGoPsutil(t *testing.T) {
fmt.Println("os:", runtime.GOOS)
fmt.Println("threads:", runtime.GOMAXPROCS(0))
v, _ := mem.VirtualMemory()
loadAvg, _ := load.Avg()
fmt.Println("loadavg", loadAvg.String())
fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
cpuTimesBefore, _ := cpu.Times(false)
time.Sleep(1000*time.Millisecond)
cpuTimesAfter, _ := cpu.Times(false)
threadNum := runtime.GOMAXPROCS(0)
fmt.Println(cpuTimesBefore[0].String(), "\n", cpuTimesAfter[0].String())
cpuUserUsage := (cpuTimesAfter[0].User - cpuTimesBefore[0].User) / (float64(1000*threadNum) / 1000)
cpuSystemUsage := (cpuTimesAfter[0].System - cpuTimesBefore[0].System) / (float64(1000*threadNum) / 1000)
fmt.Printf("%.2f, %.2f\n", cpuUserUsage*100, cpuSystemUsage*100)
diskUsage, _ := disk.Usage(".")
fmt.Println(diskUsage.String())
}