measure

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

README

Measure is a tool for help precise analysis of the performance of the goroutine, and it's designed for thread-safe. Just simply call Start() and defer End() on top of the function it will handle all the stack issue and print the tree struct result when the root function is ended.

#sample usage func processBlock() { measure.Start() defer measure.End()

......

}

#sample result |--github.com/bytom/vapor/protocol.(*Chain).processBlock: 9.009746ms (100.00) |--github.com/bytom/vapor/protocol.(*Chain).saveBlock: 8.086023ms (89.75) |--github.com/bytom/vapor/protocol.(*Chain).validateSign: 1.443966ms (17.86) |--github.com/bytom/vapor/protocol/validation.ValidateBlock: 195.333µs (2.42) |--github.com/bytom/vapor/protocol/validation.ValidateBlockHeader: 26.48µs (13.56) |--github.com/bytom/vapor/protocol/validation.ValidateTxs: 88.312µs (45.21) |--github.com/bytom/vapor/protocol.(*Chain).connectBlock: 767.073µs (8.51)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func End

func End()

End end the stack trace run time

func Start

func Start()

Start trigger record of stack trace run time record as a graph view

Types

type Timer

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

Timer is created for analysis of the function performance

func NewTimer

func NewTimer(name string) *Timer

NewTimer create a new timer, only use for root timer only

func (*Timer) EndTimer

func (t *Timer) EndTimer(stacks []string) error

EndTimer always run on end of the func

func (*Timer) IsEnd

func (t *Timer) IsEnd() bool

IsEnd check wheather the ticker is close

func (*Timer) StartTimer

func (t *Timer) StartTimer(stacks []string) error

StartTimer start track time for sub func

func (*Timer) String

func (t *Timer) String() string

String implement the print interface

Jump to

Keyboard shortcuts

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