Documentation ¶
Overview ¶
Package cpu measures CPU usage.
Index ¶
- func MeasurePowerConsumption(ctx context.Context, duration time.Duration) (float64, error)
- func MeasureProcessUsage(ctx context.Context, duration time.Duration, exitOption ExitOption, ...) (measurements map[string]float64, retErr error)
- func MeasureUsage(ctx context.Context, duration time.Duration) (map[string]float64, error)
- func SetUpBenchmark(ctx context.Context) (cleanUp func(ctx context.Context), err error)
- type ExitOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MeasurePowerConsumption ¶
MeasurePowerConsumption measures power consumption during the specified duration and returns the average power consumption (in Watts). The power consumption is acquired by reading the RAPL 'pkg' entry, which gives a measure of the total SoC power consumption.
func MeasureProcessUsage ¶
func MeasureProcessUsage(ctx context.Context, duration time.Duration, exitOption ExitOption, ts ...*gtest.GTest) (measurements map[string]float64, retErr error)
MeasureProcessUsage starts one or more gtest processes and measures CPU usage and power consumption asynchronously for the given duration. A map is returned containing CPU usage (percentage in [0-100] range) with key "cpu" and power consumption (Watts) with key "power" if supported.
func MeasureUsage ¶
MeasureUsage measures the average utilization across all CPUs and the average SoC 'pkg' power consumption during the specified duration. Measuring power consumption is currently not supported on all platforms. A map is returned containing CPU usage (percentage in [0-100] range) and power consumption (Watts) if supported.
func SetUpBenchmark ¶
SetUpBenchmark performs setup needed for running benchmarks. It disables CPU frequency scaling and thermal throttling. A deferred call to the returned cleanUp function should be scheduled by the caller if err is non-nil.
Types ¶
type ExitOption ¶
type ExitOption int
ExitOption describes how to clean up the child process upon function exit.
const ( // KillProcess option kills the child process when the function is done. KillProcess ExitOption = iota // WaitProcess option waits for the child process to finish. WaitProcess )