Documentation
¶
Overview ¶
Package cpu provides utilities to deal with CPUs on the DUT.
Index ¶
- func MeasureUsage(ctx context.Context, duration time.Duration) (float64, error)
- func Temperature(ctx context.Context) (int, string, error)
- func WaitUntilCoolDown(ctx context.Context, config CoolDownConfig) (time.Duration, error)
- func WaitUntilIdle(ctx context.Context) error
- func WaitUntilStabilized(ctx context.Context, cdConfig CoolDownConfig) error
- type CoolDownConfig
- type CoolDownMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MeasureUsage ¶
MeasureUsage measures utilization across all CPUs during duration. Returns a percentage in the range [0.0, 100.0].
func Temperature ¶
Temperature returns the CPU temperature in milli-Celsius units. It also returns the name of the thermal zone it chose.
func WaitUntilCoolDown ¶
WaitUntilCoolDown waits until CPU is cooled down and returns the time it took to cool down.
func WaitUntilIdle ¶
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 )