cpufreq

package
Version: 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: 5 Imported by: 0

Documentation

Overview

Package cpufreq provides the current CPU frequency, in MHz, as reported by /proc/cpuinfo. Instead of returning a Go struct, it returns JSON serialized bytes. A function to deserialize the JSON serialized bytes into a cpufreq.Frequency struct is provided.

Note: the package name is cpufreq and not the final element of the import path (json).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(p []byte) (*freq.Frequency, error)

Deserialize takes some JSON serialized bytes and unmarshals them as cpufreq.Frequency.

func Get

func Get() (p []byte, err error)

Get returns the frequency as JSON serialized bytes using the package's global Profiler.

func Marshal

func Marshal(f *freq.Frequency) ([]byte, error)

Marshal is an alias for Serialize using package globals.

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.

func Serialize

func Serialize(f *freq.Frequency) (p []byte, err error)

Serialize Frequency as JSON using package globals.

func Unmarshal

func Unmarshal(p []byte) (*freq.Frequency, error)

Unmarshal is an alias for Deserialize using package globals.

Types

type Profiler

type Profiler struct {
	*freq.Profiler
}

Profiler is used to process the frequency information as JSON serialized bytes.

func NewProfiler

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

Initializes and returns a cpufreq profiler.

func (*Profiler) Get

func (prof *Profiler) Get() (p []byte, err error)

Get returns the frequency as JSON serialized bytes.

func (*Profiler) Marshal

func (prof *Profiler) Marshal(f *freq.Frequency) ([]byte, error)

Marshal is an alias for serialize.

func (*Profiler) Serialize

func (prof *Profiler) Serialize(f *freq.Frequency) ([]byte, error)

Serialize Frequency as JSON.

type Ticker

type Ticker struct {
	*joe.Ticker
	Data chan []byte
	*Profiler
}

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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL