metric

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Overview

Package metric provides base types for units, measurement and statistics.

Index

Constants

View Source
const (
	Bps  Bitrate = 1
	Kbps         = 1000 * Bps
	Mbps         = 1000 * Kbps
	Gbps         = 1000 * Mbps
	Tbps         = 1000 * Gbps
)
View Source
const (
	Byte     Bytes = 1
	Kilobyte       = 1000 * Byte
	Megabyte       = 1000 * Kilobyte
	Gigabyte       = 1000 * Megabyte
	Terabyte       = 1000 * Gigabyte
	Petabyte       = 1000 * Terabyte
	Kibibyte       = 1024 * Byte
	Mebibyte       = 1024 * Kibibyte
	Gibibyte       = 1024 * Mebibyte
	Tebibyte       = 1024 * Gibibyte
	Pebibyte       = 1024 * Tebibyte
)

Variables

View Source
var Tinit = time.Now()

Tinit is the base time used for RelativeTime values.

Functions

This section is empty.

Types

type Bitrate

type Bitrate int64

Bitrate is a bitrate in bits per second.

func CalcBitrate

func CalcBitrate(bytes Bytes, dur time.Duration) Bitrate

func MaxBitrate

func MaxBitrate(bitrate ...Bitrate) (max Bitrate)

func MinBitrate

func MinBitrate(bitrate ...Bitrate) (min Bitrate)

func (Bitrate) Bps

func (b Bitrate) Bps() float64

Bps returns the Bitrate in bits per second.

func (Bitrate) Gbps

func (b Bitrate) Gbps() float64

Gbps returns the Bitrate in gigabits per second.

func (Bitrate) Kbps

func (b Bitrate) Kbps() float64

Kbps returns the Bitrate in kilobits per second.

func (Bitrate) Mbps

func (b Bitrate) Mbps() float64

Mbps returns the Bitrate in megabits per second.

func (Bitrate) Qdisc

func (b Bitrate) Qdisc() string

Qdisc returns a formatted string suitable for Linux qdisc parameters.

func (Bitrate) String

func (b Bitrate) String() string

func (Bitrate) Tbps

func (b Bitrate) Tbps() float64

Tbps returns the Bitrate in terabits per second.

type Bytes

type Bytes uint64

Bytes is a number of bytes.

func (Bytes) Gibibytes

func (b Bytes) Gibibytes() float64

Gibibytes returns the Bytes in Gibibytes.

func (Bytes) Gigabytes

func (b Bytes) Gigabytes() float64

Gigabytes returns the Bytes in Gigabytes.

func (Bytes) Kibibytes

func (b Bytes) Kibibytes() float64

Kibibytes returns the Bytes in Kibibytes.

func (Bytes) Kilobytes

func (b Bytes) Kilobytes() float64

Kilobytes returns the Bytes in Kilobytes.

func (Bytes) Mebibytes

func (b Bytes) Mebibytes() float64

Mebibytes returns the Bytes in Mebibytes.

func (Bytes) Megabytes

func (b Bytes) Megabytes() float64

Megabytes returns the Bytes in Megabytes.

func (Bytes) Pebibytes

func (b Bytes) Pebibytes() float64

Pebibytes returns the Bytes in Pebibytes.

func (Bytes) Petabytes

func (b Bytes) Petabytes() float64

Petabytes returns the Bytes in Petabytes.

func (Bytes) String

func (b Bytes) String() string

func (Bytes) Tebibytes

func (b Bytes) Tebibytes() float64

Tebibytes returns the Bytes in Tebibytes.

func (Bytes) Terabytes

func (b Bytes) Terabytes() float64

Terabytes returns the Bytes in Terabytes.

type Duration

type Duration time.Duration

Duration wraps a time.Duration and adds a TextUnmarshaler for conversion from a string, using time.ParseDuration.

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration returns the time.Duration.

func (Duration) Seconds

func (d Duration) Seconds() float64

Duration.Seconds.

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) (err error)

UnmarshalText implements encoding.TextUnmarshaler.

type RelativeTime

type RelativeTime time.Duration

RelativeTime represents a time relative to a base time.

func Now

func Now() RelativeTime

Now returns the current RelativeTime, with Tinit as a base.

func Relative

func Relative(t time.Time) RelativeTime

Relative returns the RelativeTime for t, with Tinit as a base.

func (RelativeTime) Duration

func (r RelativeTime) Duration() time.Duration

Duration returns the RelativeTime as a time.Duration.

func (RelativeTime) String

func (r RelativeTime) String() string

func (RelativeTime) Time

func (r RelativeTime) Time(base time.Time) time.Time

Time returns the absolute time for the given base time.

Jump to

Keyboard shortcuts

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