cpuKit

package
v2.8.118 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 9 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 GetFamily added in v2.1.37

func GetFamily() int

func GetFrequency added in v2.1.37

func GetFrequency() int64

func GetLogicalCores added in v2.1.37

func GetLogicalCores() int

func GetModel added in v2.1.37

func GetModel() int

func GetPhysicalCores added in v2.1.37

func GetPhysicalCores() int

func GetThreadsPerCore added in v2.1.37

func GetThreadsPerCore() int

func GetUsagePercent added in v2.1.54

func GetUsagePercent() (float64, error)

GetUsagePercent CPU使用率

PS: 耗时约1s.

e.g. () => 12.701612903175233

func GetUsagePercentByCurrentProcess added in v2.1.54

func GetUsagePercentByCurrentProcess() (float64, error)

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

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

func GetUsagePercentByProcess added in v2.1.54

func GetUsagePercentByProcess(pid int32) (float64, error)

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

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 SetUp added in v2.1.48

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