stopwatch

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 3 Imported by: 3

README

Getting Started with stopwatch

Time counter, which can be used to time the execution of the code

// new
sw := stopwatch.StartNew()

// sleep 1 second
time.Sleep(time.Second)

// print:finish,use:1000 ms
flog.Println("finish,use:" + strconv.FormatInt(sw.ElapsedMilliseconds(), 10) + " ms")
sw := stopwatch.New()
// Start or Continue timing
sw.Start
// Reset Timer
sw.Restart()
// Timer pause
sw.Stop
// Return to timed time
sw.ElapsedMilliseconds

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watch

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

func New

func New() *Watch

New 创建计时器,并开始计时

func StartNew

func StartNew() *Watch

StartNew 创建计时器,并开始计时

func (*Watch) ElapsedMicroseconds added in v0.3.0

func (sw *Watch) ElapsedMicroseconds() int64

ElapsedMicroseconds 返回当前已计时的时间(微秒)

func (*Watch) ElapsedMilliseconds

func (sw *Watch) ElapsedMilliseconds() int64

ElapsedMilliseconds 返回当前已计时的时间(毫秒)

func (*Watch) ElapsedNanoseconds added in v0.3.0

func (sw *Watch) ElapsedNanoseconds() int64

ElapsedNanoseconds 返回当前已计时的时间(纳秒)

func (*Watch) GetMicrosecondsText added in v0.3.0

func (sw *Watch) GetMicrosecondsText() string

GetMicrosecondsText 返回当前已计时的时间(微秒)

func (*Watch) GetMillisecondsText

func (sw *Watch) GetMillisecondsText() string

GetMillisecondsText 返回当前已计时的时间(毫秒)

func (*Watch) GetNanosecondsText added in v0.3.0

func (sw *Watch) GetNanosecondsText() string

GetNanosecondsText 返回当前已计时的时间(纳秒)

func (*Watch) Restart

func (sw *Watch) Restart()

Restart 重置计时器

func (*Watch) Start

func (sw *Watch) Start()

Start 继续计时

func (*Watch) Stop

func (sw *Watch) Stop()

Stop 停止计时

Jump to

Keyboard shortcuts

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