processors

package
v0.0.0-...-df36a95 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

processors

Package processors provides information about a system's nodes, sockets, and physical processors. This information is gathered from both /proc/cpuinfo and the sysfs. For information gathered from cpuinfo, the first core entry for each physical CPU is used.

For x86/x86-64 systems, the CPUMHz field is not reliable as it is the current speed of the first core processed for each physical processor. Modern x86\x86-64 processor core speeds are dynamic and fall within a range; there may be other cores on the same processor that are at higher or lower speeds than the reported value. For x86\x86-64 processors, the MHzMin and MHzMax fields provide information on the processors min and max speeds.

CPUInfo from the following processors were used for testing:

  • Intel I7 5600u
  • Intel Xeon E52690 w 2 sockets
  • AMD R7 1800x

For testing, the sysfs stuff use generated files and data. Please file an issue or a pull request for any gaps encountered.

Please file an issue or a pull request for any additional processors/architectures.

Documentation

Overview

Package processors gathers information about the physical processors on a system by parsing the information from /procs/cpuinfo and the sysfs. This package gathers basic information about sockets, physical processors, etc. on the system. For multi-socket systems, it is assumed that all of the processors are the same.

CPUMHz currently provides the current speed of the first core encountered for each physical processor. Modern x86/x86-64 cores have the ability to shift their speed so this is just a point in time data point for that core; there may be other cores on the processor that are at higher and lower speeds at the time the data is read. This field is more useful for other architectures. For x86/x86-64 cores, the MHzMin and MHzMax fields provide information about the range of speeds that are possible for the cores.

Index

Constants

View Source
const (
	BigEndian    = "Big Endian"
	LittleEndian = "Little Endian"
	VTx          = "VT-x"
	AMDV         = "AMD-V"
)

Variables

This section is empty.

Functions

func Endianness

func Endianness() string

Endianness returns the endianness. Code from Rob Pike's response in thread about endianness detection:

https://groups.google.com/d/msg/golang-nuts/zmh64YkqOV8/iJe-TrTTeREJ

Types

type Processors

type Processors struct {
	Timestamp      int64             `json:"timestamp"`
	Architecture   string            `json:"architecture"`
	ByteOrder      string            `json:"byte_order"`
	Sockets        int32             `json:"sockets"`
	CPUs           int32             `json:"cpus"`
	Possible       string            `json:"possible"`
	Present        string            `json:"present"`
	Offline        string            `json:"offline"`
	Online         string            `json:"online"`
	CoresPerSocket int16             `json:"cores_per_socket"`
	ThreadsPerCore int8              `json:"threads_per_core"`
	VendorID       string            `json:"vendor_id"`
	CPUFamily      string            `json:"cpu_family"`
	Model          string            `json:"model"`
	ModelName      string            `json:"model_name"`
	Stepping       string            `json:"stepping"`
	Microcode      string            `json:"microcode"`
	CPUMHz         float32           `json:"cpu_mhz"`
	MHzMin         float32           `json:"mhz_min"`
	MHzMax         float32           `json:"mhz_max"`
	CacheSize      string            `json:"cache_size"`
	Cache          map[string]string `json:"cache"`
	CacheIDs       []string          `json:"cache_ids"`
	BogoMIPS       float32           `json:"bogomips"`
	Flags          []string          `json:"flags"`
	Bugs           []string          `json:"bugs"`
	OpModes        []string          `json:"op_modes"`
	Virtualization string            `json:"virtualization"`
	NumaNodes      int32             `json:"numa_nodes"`
	NumaNodeCPUs   []node.Node       `json:"numa_node_cpus"`
}

Processors holds information about a system's processors

func Get

func Get() (procs *Processors, err error)

Get returns the information about the processors using the package's global Profiler.

func New

func New() *Processors

This returns a *Processor ready to use. If a Processors struct isn't created using the New func, the ByteOrder field will not be set.

type Profiler

type Profiler struct {
	joe.Procer
	*joe.Buffer
	CPUProf  *cpux.Profiler // This is created with the profiler for testing purposes.
	NodeProf *node.Profiler // This is created with the profiler for testing purposes.
}

Profiler is used to get the processor information by processing the /proc/cpuinfo file.

func NewProfiler

func NewProfiler() (prof *Profiler, err error)

Returns an initialized Profiler; ready to use.

func (*Profiler) Get

func (prof *Profiler) Get() (procs *Processors, err error)

Get returns the processor information.

func (*Profiler) Reset

func (prof *Profiler) Reset() error

Reset resources: after reset, the profiler is ready to be used again.

Directories

Path Synopsis
Package processors gathers information about the physical processors on a system by parsing the information from /procs/cpuinfo and the sysfs.
Package processors gathers information about the physical processors on a system by parsing the information from /procs/cpuinfo and the sysfs.
Package processors gathers information about the physical processors on a system by parsing the information from /procs/cpuinfo and the sysfs.
Package processors gathers information about the physical processors on a system by parsing the information from /procs/cpuinfo and the sysfs.

Jump to

Keyboard shortcuts

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