cpu

package
v0.0.0-...-9474aff Latest Latest
Warning

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

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

Documentation

Overview

Package cpu measures CPU usage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MeasurePowerConsumption

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

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

func MeasureUsage(ctx context.Context, duration time.Duration) (map[string]float64, error)

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

func SetUpBenchmark(ctx context.Context) (cleanUp func(ctx context.Context), err error)

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
)

Jump to

Keyboard shortcuts

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