measurement

Imports

Imports #

"fmt"
"math"
"strings"
"time"
"github.com/google/pprof/profile"

Constants & Variables

UnitTypes var #

UnitTypes holds the definition of units known to pprof.

var UnitTypes = []UnitType{...}

Structs

Unit struct #

Unit includes a list of aliases representing a specific unit and a factor which one can multiple a value in the specified unit by to get the value in terms of the base unit.

type Unit struct {
CanonicalName string
aliases []string
Factor float64
}

UnitType struct #

UnitType includes a list of units that are within the same category (i.e. memory or time units) and a default unit to use for this type of unit.

type UnitType struct {
DefaultUnit Unit
Units []Unit
}

Functions

CommonValueType function #

CommonValueType returns the finest type from a set of compatible types.

func CommonValueType(ts []*profile.ValueType) (*profile.ValueType, error)

Label function #

Label returns the label used to describe a certain measurement.

func Label(value int64, unit string) string

Percentage function #

Percentage computes the percentage of total of a value, and encodes it as a string. At least two digits of precision are printed.

func Percentage(value int64, total int64) string

Scale function #

Scale a measurement from a unit to a different unit and returns the scaled value and the target unit. The returned target unit will be empty if uninteresting (could be skipped).

func Scale(value int64, fromUnit string, toUnit string) (float64, string)

ScaleProfiles function #

ScaleProfiles updates the units in a set of profiles to make them compatible. It scales the profiles to the smallest unit to preserve data.

func ScaleProfiles(profiles []*profile.Profile) error

ScaledLabel function #

ScaledLabel scales the passed-in measurement (if necessary) and returns the label used to describe a float measurement.

func ScaledLabel(value int64, fromUnit string, toUnit string) string

autoScale method #

autoScale takes in the value with units of the base unit and returns that value scaled to a reasonable unit if a reasonable unit is found.

func (ut UnitType) autoScale(value float64) (float64, string, bool)

compatibleValueTypes function #

func compatibleValueTypes(v1 *profile.ValueType, v2 *profile.ValueType) bool

convertUnit method #

convertUnit converts a value from the fromUnit to the toUnit, autoscaling the value if the toUnit is "minimum" or "auto". If the fromUnit is not included in the unitType, then a false boolean will be returned. If the toUnit is not in the unitType, the value will be returned in terms of the default unitType.

func (ut UnitType) convertUnit(value int64, fromUnitStr string, toUnitStr string) (float64, string, bool)

findByAlias method #

findByAlias returns the unit associated with the specified alias. It returns nil if the unit with such alias is not found.

func (ut UnitType) findByAlias(alias string) *Unit

sniffUnit method #

sniffUnit simpifies the input alias and returns the unit associated with the specified alias. It returns nil if the unit with such alias is not found.

func (ut UnitType) sniffUnit(unit string) *Unit

Generated with Arrow