speed

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After added in v0.7.7

func After(n int, suffix string) <-chan time.Time

After is a convenient wrapper for time.After

func Now added in v0.7.7

func Now() func() T

Now makes a new time measurement starting now.

t0 := speed.Now()
<-time.After(100*time.Millisecond)
t0() // 101.383ms

func Trunc added in v0.7.7

func Trunc(d time.Duration, digits int) string

Types

type B

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

B is a benchmark ring.

Non-zero length B's function as a ring, effectively rewriting old frames with the new ones. Zero length B's grow normally.

func Many

func Many(ringSize ...int) B

Many constructs a benchmark.

func (*B) Add added in v0.7.7

func (b *B) Add(t T, value ...float64)

Adds pushes a time frame to the benchmark ring.

func (B) Avg added in v0.7.7

func (b B) Avg() (t time.Duration, k float64)

Avg corresponds to the arithmetic average.

func (B) Avgk added in v0.7.7

func (b B) Avgk() float64

Avgk returns the average of stored values in the ring.

func (B) Avgt added in v0.7.7

func (b B) Avgt() time.Duration

Avgt returns the average duration of all measurements.

func (B) Cap added in v0.7.7

func (b B) Cap() int

Len is the capacity of the underlying slice.

func (B) Format

func (b B) Format(state fmt.State, verb rune)

func (B) Len added in v0.7.7

func (b B) Len() int

Len is the number of items in the underlying slice.

func (B) Ordered added in v0.7.7

func (b B) Ordered() []T

Ordered returns the list of frames adjusted for ring position.

func (B) Std added in v0.7.7

func (b B) Std() (t time.Duration, k float64)

Std corresponds to the standard deviation.

func (B) Stdk added in v0.7.7

func (b B) Stdk() float64

Avgt returns the standard deviation of the K-values.

func (B) Stdt added in v0.7.7

func (b B) Stdt() time.Duration

Avgt returns the standard deviation of the durations.

func (B) Unordered added in v0.7.7

func (b B) Unordered() []T

Unordered returns the list of time frames as-is.

type T

type T struct {
	time.Duration
	// K is a number associated with the time frame.
	K float64
	// contains filtered or unexported fields
}

T is a time frame.

func Of

func Of(f func()) T

Of measures function run time.

func (T) Format

func (t T) Format(state fmt.State, verb rune)

func (T) Left added in v0.7.7

func (t T) Left() time.Time

func (T) MarshalJSON added in v0.7.9

func (t T) MarshalJSON() ([]byte, error)

func (T) Right added in v0.7.7

func (t T) Right() time.Time

Jump to

Keyboard shortcuts

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