Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package trackers
import "time"
type tracker struct {
label string
startTime time.Time
}
func Begin(label string) *tracker {
return &tracker{label: label, startTime: time.Now()}
}
func Run(label string, f func()) {
var tr = Begin(label)
f()
tr.End()
}
func (this *tracker) End() {
SharedManager.Add(this.label, time.Since(this.startTime).Seconds()*1000)
}
func (this *tracker) Begin(subLabel string) *tracker {
return Begin(this.label + ":" + subLabel)
}
func (this *tracker) Add(duration time.Duration) {
this.startTime = this.startTime.Add(-duration)
}