cpuKit

package
v3.0.906 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetCpuNumber func() int = runtime.NumCPU

GetCpuNumber returns the number of logical CPUs usable by the current process.

View Source
var GetFeatureSet func() []string = cpuid.CPU.FeatureSet

GetFeatureSet 获取CPU支持的指令集s.

Linux命令: cat /proc/cpuinfo

View Source
var InVirtualMachine func() bool = cpuid.CPU.VM

InVirtualMachine 是否在虚拟机中?

Functions

func GetBrandName

func GetBrandName() string

GetBrandName CPU品牌名称

@return e.g."Apple M1 Pro"

func GetCpuId

func GetCpuId() (string, error)

GetCpuId

PS: cpu.Info() 目前仅支持Windows环境,不支持:Mac环境(M1)、Linux环境.

Linux下用命令查看CPU ID: https://blog.csdn.net/benwdm/article/details/84685292

func GetCurrentProcessUsagePercent

func GetCurrentProcessUsagePercent() (float64, error)

GetCurrentProcessUsagePercent 获取 当前进程 的CPU使用百分比.

PS: 类似Linux命令: top -p ${pid}

func GetFamily

func GetFamily() int

func GetFrequency

func GetFrequency() int64

func GetLogicalCores

func GetLogicalCores() int

func GetModel

func GetModel() int

func GetPhysicalCores

func GetPhysicalCores() int

func GetProcessUsagePercent

func GetProcessUsagePercent(pid int32) (float64, error)

GetProcessUsagePercent 获取 指定进程 的CPU使用百分比.

func GetThreadsPerCore

func GetThreadsPerCore() int

func GetUsagePercent

func GetUsagePercent() (float64, error)

GetUsagePercent CPU使用率

PS: 耗时约1s.

e.g. () => 12.701612903175233

func GetVendorID

func GetVendorID() cpuid.Vendor

func GetVendorString

func GetVendorString() string

GetVendorString CPU供应商

@return e.g."Apple"

func HasFeature

func HasFeature(id cpuid.FeatureID) bool

HasFeature CPU是否支持特定指令集?

@param id e.g. cpuid.AVX

func PrintBasicDetails

func PrintBasicDetails(logger *logrus.Logger)

func SetUp

func SetUp()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL