timeutil

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LatencyRecorder

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

LatencyRecorder helps to record operation latencies.

func NewLatencyRecorder

func NewLatencyRecorder() *LatencyRecorder

NewLatencyRecorder creates a new LatencyRecorder.

func (*LatencyRecorder) Format

func (p *LatencyRecorder) Format() string

Format formats the recorded latencies into a string, which can be sent to log by a logger.

func (*LatencyRecorder) GetLatencyMap

func (p *LatencyRecorder) GetLatencyMap() map[string]time.Duration

GetLatencyMap returns a map of all recorded latencies.

func (*LatencyRecorder) Mark

func (p *LatencyRecorder) Mark(name string)

Mark records latency of an operation, from the previous operation, or from the startTime if this is the first calling. It is designed to record each operation latency one by one in synchronous operations.

func (*LatencyRecorder) MarkFromStartTime

func (p *LatencyRecorder) MarkFromStartTime(name string)

MarkFromStartTime records latency of an operation, from the startTime, it does not affect recording of calling Mark.

func (*LatencyRecorder) MarkWithStartTime

func (p *LatencyRecorder) MarkWithStartTime(name string, start time.Time)

MarkWithStartTime records latency of an operation, from the given time, it does not affect recording of calling Mark.

func (*LatencyRecorder) Reset

func (p *LatencyRecorder) Reset()

Reset resets the recorder to initial state, which is ready to be reused.

func (*LatencyRecorder) WriteTo

func (p *LatencyRecorder) WriteTo(w io.Writer) (n int64, err error)

WriteTo formats and writes the recorded latencies to the given io.Writer. It implements the interface io.WriterTo,

Jump to

Keyboard shortcuts

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