stats

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MeasureNotValid       = Measure(invalid)
	MeasureNotInitialized = Measure(invalid - 1)
)

Some variables for invalid measures. Naming should be explicit enough

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterable added in v1.1.0

type Iterable interface {
	Iterator() Iterator
}

Iterable is used to define a collection providing an Iterator

type Iterator added in v1.1.0

type Iterator interface {
	HasNext() bool
	Next() Observation
}

Iterator is used to iterate over Observation

type Measure

type Measure time.Duration

Measure represent a time measurement which can be successful or not

func (Measure) Divide

func (m Measure) Divide(n int64) Measure

Divide returns the result of the division of a measure with n if the measure is invalid the returned value is invalid as well

func (Measure) IsSuccess

func (m Measure) IsSuccess() bool

IsSuccess returns true if the measurement is valid and positive.

func (Measure) IsValid

func (m Measure) IsValid() bool

IsValid returns true if the measurement is valid (might be negative (!), but is the difference between two time measurements

func (Measure) SumIfValid

func (m Measure) SumIfValid(o Measure) Measure

SumIfValid returns - if both measures are valid: the sum of them - if one of them is invalid, it returns this specific one - otherwise it returns an invalid measure

func (Measure) ToFloat

func (m Measure) ToFloat(unit time.Duration) float64

ToFloat converts the current measurement to a float in a specified unit

type MeasuresCollection added in v1.2.3

type MeasuresCollection struct {
	// contains filtered or unexported fields
}

func NewMeasureRegistry added in v1.2.3

func NewMeasureRegistry() *MeasuresCollection

func (*MeasuresCollection) Append added in v1.2.3

func (mr *MeasuresCollection) Append(other *MeasuresCollection)

func (*MeasuresCollection) Divide added in v1.2.3

func (mr *MeasuresCollection) Divide(successes int64)

func (*MeasuresCollection) Get added in v1.2.3

func (mr *MeasuresCollection) Get(tt TimerType) Measure

func (*MeasuresCollection) Set added in v1.2.3

func (mr *MeasuresCollection) Set(tt TimerType, m Measure)

type Observation added in v1.1.0

type Observation struct {
	Value  float64
	Weight float64
}

Observation represents an item in the population we would extract statistics

type PingStats

type PingStats struct {
	Average Measure
	Min     Measure
	Max     Measure
	StdDev  Measure
}

PingStats represents the statistics which can be computed from an array of latencies

func PingStatsFromLatencies

func PingStatsFromLatencies(measures []Measure) *PingStats

PingStatsFromLatencies computes PingStats from a serie of ping measurements.

func (*PingStats) String

func (ps *PingStats) String() string

type Stats added in v1.1.0

type Stats struct {
	Average float64
	Min     float64
	Max     float64
	StdDev  float64
}

Stats is the type returned by ComputeStats

func ComputeStats added in v1.1.0

func ComputeStats(collection Iterable) *Stats

ComputeStats return statistical information about collection as Stats instance

type Timer added in v1.2.3

type Timer struct {
	// contains filtered or unexported fields
}

func NewTimer added in v1.2.3

func NewTimer() *Timer

func (*Timer) Duration added in v1.2.3

func (t *Timer) Duration() time.Duration

func (*Timer) Start added in v1.2.3

func (t *Timer) Start()

func (*Timer) StartForce added in v1.2.4

func (t *Timer) StartForce()

func (*Timer) Stop added in v1.2.3

func (t *Timer) Stop()

type TimerRegistry added in v1.2.3

type TimerRegistry struct {
	// contains filtered or unexported fields
}

func NewTimersCollection added in v1.2.3

func NewTimersCollection() *TimerRegistry

func (*TimerRegistry) Get added in v1.2.3

func (tr *TimerRegistry) Get(timerType TimerType) *Timer

func (*TimerRegistry) Measure added in v1.2.3

func (tr *TimerRegistry) Measure() *MeasuresCollection

type TimerType added in v1.2.3

type TimerType int
const (
	Total TimerType = iota
	Conn
	DNS
	TLS
	QUIC
	TCP
	Req
	Wait
	Resp
	ReqAndWait // temporary for http3, since Req and Wait cannot be distinguished yet with quic-go
)

Jump to

Keyboard shortcuts

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