Documentation ¶
Index ¶
- Variables
- func GetBrandName() string
- func GetCpuId() (string, error)
- func GetCurrentProcessUsagePercent() (float64, error)
- func GetFamily() int
- func GetFrequency() int64
- func GetLogicalCores() int
- func GetModel() int
- func GetPhysicalCores() int
- func GetProcessUsagePercent(pid int32) (float64, error)
- func GetThreadsPerCore() int
- func GetUsagePercent() (float64, error)
- func GetVendorID() cpuid.Vendor
- func GetVendorString() string
- func HasFeature(id cpuid.FeatureID) bool
- func PrintBasicDetails(logger *logrus.Logger)
- func SetUp()
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 GetCpuId ¶
GetCpuId
PS: cpu.Info() 目前仅支持Windows环境,不支持:Mac环境(M1)、Linux环境.
Linux下用命令查看CPU ID: https://blog.csdn.net/benwdm/article/details/84685292
func GetCurrentProcessUsagePercent ¶ added in v2.8.167
GetCurrentProcessUsagePercent 获取 当前进程 的CPU使用百分比.
PS: 类似Linux命令: top -p ${pid}
func GetFrequency ¶ added in v2.1.37
func GetFrequency() int64
func GetLogicalCores ¶ added in v2.1.37
func GetLogicalCores() int
func GetPhysicalCores ¶ added in v2.1.37
func GetPhysicalCores() int
func GetProcessUsagePercent ¶ added in v2.8.167
GetProcessUsagePercent 获取 指定进程 的CPU使用百分比.
func GetThreadsPerCore ¶ added in v2.1.37
func GetThreadsPerCore() int
func GetUsagePercent ¶ added in v2.1.54
GetUsagePercent CPU使用率
PS: 耗时约1s.
e.g. () => 12.701612903175233
func GetVendorID ¶ added in v2.1.37
func GetVendorID() cpuid.Vendor
func GetVendorString ¶ added in v2.1.37
func GetVendorString() string
GetVendorString CPU供应商
@return e.g."Apple"
func HasFeature ¶ added in v2.1.53
func HasFeature(id cpuid.FeatureID) bool
HasFeature CPU是否支持特定指令集?
@param id e.g. cpuid.AVX
func PrintBasicDetails ¶ added in v2.8.167
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.