cpufreq

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cpufreq provides the current CPU frequency, in MHz, as reported by /proc/cpuinfo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTicker

func NewTicker(d time.Duration) (joe.Tocker, error)

NewTicker returns a new Ticker containing a Data channel that delivers the data at intervals and an error channel that delivers any errors encountered. Stop the ticker to signal the ticker to stop running. Stopping the ticker does not close the Data channel; call Close to close both the ticker and the data channel.

Types

type CPU

type CPU struct {
	Processor  int32   `json:"processor"`
	CPUMHz     float32 `json:"cpu_mhz"`
	PhysicalID int32   `json:"physical_id"`
	CoreID     int32   `json:"core_id"`
	APICID     int32   `json:"apicid"`
}

CPU holds the clock info for a single processor.

type Frequency

type Frequency struct {
	Timestamp int64 `json:"timestamp"`
	Sockets   int32 `json:"sockets"`
	CPU       []CPU `json:"cpu"`
}

Frequency holds information about the current frequency of a system's cpus, in MHz. The reported values are the current speeds as reported by /proc/cpuinfo.

func Get

func Get() (f *Frequency, err error)

Get returns Frequency using the package's global Profiler.

type Profiler

type Profiler struct {
	joe.Procer
	*joe.Buffer
	Frequency // this is used too hold the socket/cpu info so that everything doesn't have to be reprocessed.
}

Profiler is used to process the frequency information.

func NewProfiler

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

Returns an initialized Profiler; ready to use.

func (*Profiler) Get

func (prof *Profiler) Get() (f *Frequency, err error)

Get returns Frequency information.

func (*Profiler) InitFrequency

func (prof *Profiler) InitFrequency() error

InitFrequency sets the profiler's frequency with the static information so that everything doesn't need to be reprocessed every time the frequency is requested. This assumes that cpuinfo returns processor information in the same order every time.

This shouldn't be used; it's exported for testing reasons.

func (*Profiler) Reset

func (prof *Profiler) Reset() error

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

type Ticker

type Ticker struct {
	*joe.Ticker
	Data chan *Frequency
	*Profiler
	Sockets uint8
}

Ticker delivers the CPU Frequencies at intervals.

func (*Ticker) Close

func (t *Ticker) Close()

Close closes the ticker resources.

func (*Ticker) Run

func (t *Ticker) Run()

Run runs the ticker.

Directories

Path Synopsis
Package cpufreq provides the current CPU frequency, in MHz, as reported by /proc/cpuinfo.
Package cpufreq provides the current CPU frequency, in MHz, as reported by /proc/cpuinfo.
Package cpufreq provides the current CPU frequency, in MHz, as reported by /proc/cpuinfo.
Package cpufreq provides the current CPU frequency, in MHz, as reported by /proc/cpuinfo.

Jump to

Keyboard shortcuts

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