cpu

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {

	// TotalCores is the total number of physical cores the host system
	// contains
	TotalCores uint32 `json:"total_cores"`
	// TotalThreads is the total number of hardware threads the host system
	// contains
	TotalThreads uint32 `json:"total_threads"`
	// Processors is a slice of Processor struct pointers, one for each
	// physical processor package contained in the host
	Processors []*Processor `json:"processors"`
	// contains filtered or unexported fields
}

Info describes all central processing unit (CPU) functionality on a host. Returned by the `ghw.CPU()` function.

func New

func New(opts ...*option.Option) (*Info, error)

New returns a pointer to an Info struct that contains information about the CPUs on the host system

func (*Info) JSONString

func (i *Info) JSONString(indent bool) string

JSONString returns a string with the cpu information formatted as JSON under a top-level "cpu:" key

func (*Info) String

func (i *Info) String() string

String returns a short string indicating a summary of CPU information

func (*Info) YAMLString

func (i *Info) YAMLString() string

YAMLString returns a string with the cpu information formatted as YAML under a top-level "cpu:" key

type Processor

type Processor struct {
	// ID is the physical processor `uint32` ID according to the system
	ID int `json:"id"`
	// NumCores is the number of physical cores in the processor package
	NumCores uint32 `json:"total_cores"`
	// NumThreads is the number of hardware threads in the processor package
	NumThreads uint32 `json:"total_threads"`
	// Vendor is a string containing the vendor name
	Vendor string `json:"vendor"`
	// Model` is a string containing the vendor's model name
	Model string `json:"model"`
	// Capabilities is a slice of strings indicating the features the processor
	// has enabled
	Capabilities []string `json:"capabilities"`
	// Cores is a slice of ProcessorCore` struct pointers that are packed onto
	// this physical processor
	Cores []*ProcessorCore `json:"cores"`
}

Processor describes a physical host central processing unit (CPU).

func (*Processor) CoreByID added in v0.12.0

func (p *Processor) CoreByID(coreID int) *ProcessorCore

CoreByID returns the ProcessorCore having the supplied ID.

func (*Processor) HasCapability

func (p *Processor) HasCapability(find string) bool

HasCapability returns true if the Processor has the supplied cpuid capability, false otherwise. Example of cpuid capabilities would be 'vmx' or 'sse4_2'. To see a list of potential cpuid capabilitiies, see the section on CPUID feature bits in the following article:

https://en.wikipedia.org/wiki/CPUID

func (*Processor) String

func (p *Processor) String() string

String returns a short string describing the Processor

type ProcessorCore

type ProcessorCore struct {
	// ID is the `uint32` identifier that the host gave this core. Note that
	// this does *not* necessarily equate to a zero-based index of the core
	// within a physical package. For example, the core IDs for an Intel Core
	// i7 are 0, 1, 2, 8, 9, and 10
	ID int `json:"id"`
	// NumThreads is the number of hardware threads associated with the core
	NumThreads uint32 `json:"total_threads"`
	// LogicalProcessors is a slice of ints representing the logical processor
	// IDs assigned to any processing unit for the core. These are sometimes
	// called the "thread siblings". Logical processor IDs are the *zero-based*
	// index of the processor on the host and are *not* related to the core ID.
	LogicalProcessors []int `json:"logical_processors"`
}

ProcessorCore describes a physical host processor core. A processor core is a separate processing unit within some types of central processing units (CPU).

func CoresForNode

func CoresForNode(ctx *context.Context, nodeID int) ([]*ProcessorCore, error)

func (*ProcessorCore) String

func (c *ProcessorCore) String() string

String returns a short string indicating important information about the processor core

Jump to

Keyboard shortcuts

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