mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
util: add TimeProfile
This commit is contained in:
parent
e276ddd38a
commit
15ed802a54
22
pkg/util/profile.go
Normal file
22
pkg/util/profile.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package util
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type TimeProfile struct {
|
||||||
|
StartTime, EndTime time.Time
|
||||||
|
Duration time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func StartTimeProfile() TimeProfile {
|
||||||
|
return TimeProfile{StartTime: time.Now()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *TimeProfile) TilNow() time.Duration {
|
||||||
|
return time.Now().Sub(p.StartTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *TimeProfile) Stop() time.Duration {
|
||||||
|
p.EndTime = time.Now()
|
||||||
|
p.Duration = p.EndTime.Sub(p.StartTime)
|
||||||
|
return p.Duration
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user