cpu

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package cpu provides utilities to deal with CPUs on the DUT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MeasureUsage

func MeasureUsage(ctx context.Context, duration time.Duration) (float64, error)

MeasureUsage measures utilization across all CPUs during duration. Returns a percentage in the range [0.0, 100.0].

func Temperature

func Temperature(ctx context.Context) (int, string, error)

Temperature returns the CPU temperature in milli-Celsius units. It also returns the name of the thermal zone it chose.

func WaitUntilCoolDown

func WaitUntilCoolDown(ctx context.Context, config CoolDownConfig) (time.Duration, error)

WaitUntilCoolDown waits until CPU is cooled down and returns the time it took to cool down.

func WaitUntilIdle

func WaitUntilIdle(ctx context.Context) error

WaitUntilIdle waits until the CPU is idle, for a maximum of 120s. The CPU is considered idle if the average usage over all CPU cores is less than 5%. This percentage will be gradually increased to 20%, as older boards might have a hard time getting below 5%.

func WaitUntilStabilized

func WaitUntilStabilized(ctx context.Context, cdConfig CoolDownConfig) error

WaitUntilStabilized waits for the stabilization of the CPU. Currently, this waits for two conditions, one is the CPU's cooldown, and the other is the CPU idle.

Types

type CoolDownConfig

type CoolDownConfig struct {
	PollTimeout  time.Duration
	PollInterval time.Duration
	// TemperatureThreshold is the threshold for CPU temperature.
	TemperatureThreshold int
	CoolDownMode         CoolDownMode
}

CoolDownConfig contains the config to wait for the machine to cooldown.

func DefaultCoolDownConfig

func DefaultCoolDownConfig(mode CoolDownMode) CoolDownConfig

DefaultCoolDownConfig returns the default config to wait for the machine to cooldown.

type CoolDownMode

type CoolDownMode int

CoolDownMode defines various modes how to do cool down.

const (
	// CoolDownPreserveUI defines the mode when current Chrome UI is preserved.
	CoolDownPreserveUI CoolDownMode = iota
	// CoolDownStopUI defines the mode when current Chrome UI is stopped in order to get cool down
	// faster. However, in this mode current Chrome state is lost.
	CoolDownStopUI
)

Jump to

Keyboard shortcuts

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