timex

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentMicros

func CurrentMicros() int64

CurrentMicros returns the current microseconds.

func CurrentMillis

func CurrentMillis() int64

CurrentMillis returns the current milliseconds.

func Duration

func Duration(duration time.Duration) float64

Duration returns the float64 representation of given duration in ms.

func Now

func Now() time.Duration

Now returns a relative time duration since initTime, which is not important. The caller only needs to care about the relative value.

func ReprOfDuration

func ReprOfDuration(duration time.Duration) string

ReprOfDuration returns the string representation of given duration in ms.

func Since

func Since(d time.Duration) time.Duration

Since returns a diff since given d.

func Time

func Time() time.Time

Time returns current time, the same as time.Now().

Types

type ElapsedTimer

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

A ElapsedTimer is a timer to track the elapsed time.

func NewElapsedTimer

func NewElapsedTimer() *ElapsedTimer

NewElapsedTimer returns a ElapsedTimer.

func (*ElapsedTimer) Duration

func (et *ElapsedTimer) Duration() time.Duration

Duration returns the elapsed time.

func (*ElapsedTimer) Elapsed

func (et *ElapsedTimer) Elapsed() string

Elapsed returns the string representation of elapsed time.

func (*ElapsedTimer) ElapsedMs

func (et *ElapsedTimer) ElapsedMs() string

ElapsedMs returns the elapsed time of string on milliseconds.

type FakeTicker

type FakeTicker interface {
	Ticker
	Done()
	Tick()
	Wait(d time.Duration) error
}

FakeTicker interface is used for unit testing.

func NewFakeTicker

func NewFakeTicker() FakeTicker

NewFakeTicker returns a FakeTicker.

type Ticker

type Ticker interface {
	Chan() <-chan time.Time
	Stop()
}

Ticker interface wraps the Chan and Stop methods.

func NewTicker

func NewTicker(d time.Duration) Ticker

NewTicker returns a Ticker.

Jump to

Keyboard shortcuts

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