timing

package
v1.5.50 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt func(profiling *timeProfiling)

Opt is a type for implementing functional options pattern

func WithMsgFormat

func WithMsgFormat(msgTemplate string) Opt

WithMsgFormat specify a msg-format string such as "xxx takes %v"

func WithWriter

func WithWriter(w Writer) Opt

WithWriter specify a msg printer/formmater

type P

type P interface {
	// WithWriter allows putting a printer for dump the timing information
	WithWriter(writer Writer) P
	// WithoutWriter could clear the internal writer
	WithoutWriter() P
	// Duration returns the timing result of an invocation
	Duration() time.Duration
}

P is a timing tool interface type

func New

func New(opts ...Opt) P

New returns a timing tool for calculating the elapsed time in time.Duration

type Writer

type Writer func(msg string, args ...interface{})

Writer is a formatter and printer such as log.Printf, t.Logf, ...

Jump to

Keyboard shortcuts

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