utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 15

Documentation

Index

Constants

View Source
const (
	SysfsUncoreBasepath = "sys/devices/system/cpu/intel_uncore_frequency"
	SysfsCpuBasepath    = "sys/devices/system/cpu"
)

Variables

This section is empty.

Functions

func DumpJSON

func DumpJSON(r interface{}) string

DumpJSON dumps a json-compatible struct in human-readable form

func GetCPUFreqValue added in v0.3.0

func GetCPUFreqValue(cpu ID, setting string) (int, error)

GetCPUFreqValue returns information of the currently used CPU frequency

func ReadMSR added in v0.3.0

func ReadMSR(cpu ID, msr int64) (uint64, error)

func SetCPUScalingMaxFreq added in v0.3.0

func SetCPUScalingMaxFreq(cpu ID, freq int) error

SetCPUScalingMaxFreq sets the scaling_max_freq value of a given CPU

func SetCPUScalingMinFreq added in v0.3.0

func SetCPUScalingMinFreq(cpu ID, freq int) error

SetCPUScalingMinFreq sets the scaling_min_freq value of a given CPU

func SetCPUsScalingMaxFreq added in v0.3.0

func SetCPUsScalingMaxFreq(cpus []ID, freq int) error

SetCPUsScalingMaxFreq sets the scaling_max_freq value of a given set of CPUs

func SetCPUsScalingMinFreq added in v0.3.0

func SetCPUsScalingMinFreq(cpus []ID, freq int) error

SetCPUsScalingMinFreq sets the scaling_min_freq value of a given set of CPUs

func SetUncoreMaxFreq added in v0.3.0

func SetUncoreMaxFreq(pkg, die ID, freqKhz int) error

SetUncoreMaxFreq sets the maximum uncore frequency of a CPU die. Frequency is specified in kHz.

func SetUncoreMinFreq added in v0.3.0

func SetUncoreMinFreq(pkg, die ID, freqKhz int) error

SetUncoreMinFreq sets the minimum uncore frequency of a CPU die. Frequency is specified in kHz.

func SortUint64s

func SortUint64s(a []uint64)

SortUint64s sorts a slice of uint64 in increasing order.

func UncoreFreqAvailable added in v0.3.0

func UncoreFreqAvailable() bool

UncoreFreqAvailable returns true if the uncore frequency control functions are available.

Types

type ID added in v0.2.0

type ID = int

ID is nn integer id, used to identify packages, CPUs, nodes, etc.

const (
	// Unknown represents an unknown id.
	Unknown ID = -1
)

type IDSet added in v0.2.0

type IDSet map[ID]struct{}

IDSet is an unordered set of integer ids.

func NewIDSet added in v0.2.0

func NewIDSet(ids ...ID) IDSet

NewIDSet creates a new unordered set of (integer) ids.

func NewIDSetFromIntSlice added in v0.2.0

func NewIDSetFromIntSlice(ids ...int) IDSet

NewIDSetFromIntSlice creates a new unordered set from an integer slice.

func (IDSet) Add added in v0.2.0

func (s IDSet) Add(ids ...ID)

Add adds the given ids into the set.

func (IDSet) Clone added in v0.2.0

func (s IDSet) Clone() IDSet

Clone returns a copy of this IdSet.

func (IDSet) Del added in v0.2.0

func (s IDSet) Del(ids ...ID)

Del deletes the given ids from the set.

func (IDSet) Has added in v0.2.0

func (s IDSet) Has(ids ...ID) bool

Has tests if all the ids are present in the set.

func (IDSet) MarshalJSON added in v0.2.0

func (s IDSet) MarshalJSON() ([]byte, error)

MarshalJSON is the JSON marshaller for IDSet.

func (IDSet) Members added in v0.2.0

func (s IDSet) Members() []ID

Members returns all ids in the set as a randomly ordered slice.

func (IDSet) Size added in v0.2.0

func (s IDSet) Size() int

Size returns the number of ids in the set.

func (IDSet) SortedMembers added in v0.2.0

func (s IDSet) SortedMembers() []ID

SortedMembers returns all ids in the set as a sorted slice.

func (IDSet) String added in v0.2.0

func (s IDSet) String() string

String returns the set as a string.

func (IDSet) StringWithSeparator added in v0.2.0

func (s IDSet) StringWithSeparator(args ...string) string

StringWithSeparator returns the set as a string, separated with the given separator.

func (*IDSet) UnmarshalJSON added in v0.2.0

func (s *IDSet) UnmarshalJSON(data []byte) error

UnmarshalJSON is the JSON unmarshaller for IDSet.

type Uint64Slice

type Uint64Slice []uint64

Uint64Slice implmenents sort.Interface for a slice of uint64.

func (Uint64Slice) Len

func (s Uint64Slice) Len() int

Len returns the length of an UintSlice

func (Uint64Slice) Less

func (s Uint64Slice) Less(i, j int) bool

Less returns true if element at 'i' is less than the element at 'j'

func (Uint64Slice) Swap

func (s Uint64Slice) Swap(i, j int)

Swap swaps the values of two elements

Jump to

Keyboard shortcuts

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