timex

package
v0.0.0-...-09c63dc Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Author:ydy Date: Desc:

Author:ydy Date: Desc:

Author:ydy Date: Desc:

Author:ydy Date: Desc:

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 Now

func Now() time.Duration

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

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 timex, 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