cpufreq

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// FrequencySourceSysfs indicates the value came from the cpufreq sysfs interface.
	FrequencySourceSysfs = "sysfs"
	// FrequencySourceProcCPU indicates the value came from /proc/cpuinfo via gopsutil.
	FrequencySourceProcCPU = "procfs"
	// FrequencySourcePerf indicates the value was derived from perf counters.
	FrequencySourcePerf = "perf"
	// FrequencySourceHostfreq indicates the value was provided by the macOS host helper.
	FrequencySourceHostfreq = "hostfreq"
)

Variables

View Source
var ErrFrequencyUnavailable = errors.New("cpu frequency data unavailable")

ErrFrequencyUnavailable is returned when no frequency data could be gathered.

Functions

func NewCollector

func NewCollector(window time.Duration) func(context.Context) (*Snapshot, error)

NewCollector returns a collection function that samples using the provided window.

func StartHostfreqSampler

func StartHostfreqSampler(context.Context) error

func StopHostfreqSampler

func StopHostfreqSampler()

Types

type ClusterFrequency

type ClusterFrequency struct {
	Name        string  // cluster label (e.g. ECPU, PCPU)
	FrequencyHz float64 // instantaneous frequency in Hz
	Source      string  // data source used
}

ClusterFrequency represents the current frequency reading for a CPU cluster.

type CoreFrequency

type CoreFrequency struct {
	CoreID      int     // zero-based logical core ID
	Label       string  // platform-specific identifier (e.g. ECPU0)
	Cluster     string  // logical cluster this core belongs to (e.g. ECPU)
	FrequencyHz float64 // instantaneous frequency in Hz
	Source      string  // data source used (sysfs, procfs, perf, hostfreq)
}

CoreFrequency represents the current frequency reading for a logical CPU.

type Snapshot

type Snapshot struct {
	Cores    []CoreFrequency
	Clusters []ClusterFrequency
}

Snapshot contains a collection of per-core frequency readings.

func Collect

func Collect(ctx context.Context) (*Snapshot, error)

Collect gathers per-core CPU frequency readings using cpufreq sysfs where available, falling back to data exposed via /proc/cpuinfo through gopsutil and perf counters.

Jump to

Keyboard shortcuts

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