costtime

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cost added in v0.2.0

func Cost(run func())

Cost 里面计算消耗时间

func CostLog added in v0.2.0

func CostLog(name string, run func())

CostLog 计算消耗的时间

func SetEventCost added in v1.0.0

func SetEventCost(event EventFunc)

SetEventCost 设置输出cost事件. 可以做邮件通知. 钉釘等办公通知

func SetLogCondition added in v0.2.0

func SetLogCondition(cond ConditionFunc)

SetLogCondition 设置输出cost条件

Types

type ConditionFunc added in v0.3.0

type ConditionFunc func(cost time.Duration) bool

ConditionFunc 日志输出条件判断函数

func CondGT added in v0.3.0

func CondGT(t time.Duration) ConditionFunc

CondGT 创建cost>t时间输出日志的条件

func CondGTE added in v0.3.0

func CondGTE(t time.Duration) ConditionFunc

CondGTE 创建cost>=t时间输出日志的条件

func CondLT added in v0.3.0

func CondLT(t time.Duration) ConditionFunc

CondLT 创建cost<t时间输出日志的条件

func CondLTE added in v0.3.0

func CondLTE(t time.Duration) ConditionFunc

CondLTE 创建cost<=t时间输出日志的条件

func CondRange added in v0.3.0

func CondRange(t1, t2 time.Duration) ConditionFunc

CondRange 创建t1<=cost<=t2时间输出日志的条件

type CostTime

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

CostTime 消费时间基本结构

func New added in v0.4.0

func New(fname string) *CostTime

New 创建一个新Cost. 每个协程里都要创建独立一个

func (*CostTime) Cost added in v0.4.0

func (c *CostTime) Cost(run func())

Cost 里面计算消耗时间

func (*CostTime) CostLog added in v0.4.0

func (c *CostTime) CostLog(name string, run func())

CostLog 计算消耗的时间

func (*CostTime) SetEeventCost added in v1.0.0

func (c *CostTime) SetEeventCost(event EventFunc)

SetEeventCost 设置输出cost事件. 可以做邮件通知. 钉釘等办公通知. 只触发CostLog(). Cost()不触发

func (*CostTime) SetLogCondition added in v0.4.0

func (c *CostTime) SetLogCondition(cond ConditionFunc)

SetLogCondition 设置输出cost条件

type EventFunc added in v1.0.0

type EventFunc func(name string, cost time.Duration)

EventFunc 日志输出条件判断函数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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