Exemplo n.º 1
0
func (this *TimeWatcher) Stop() {
	defer FreeWatcher(this)
	d := time.Now().Sub(this.tStart)
	if Config.SlowMS > 0 && d >= time.Duration(Config.SlowMS)*time.Millisecond {
		logger.Warnf("###slow timespan name: %s  take:%s", strings.ToLower(this.name), utils.ToS(d))
	}
	TimeStatisticMgr.addStatistic(this.name, d)
}
Exemplo n.º 2
0
func (this *timeStatisticMgr) dump(w io.Writer) {
	this.l.Lock()
	defer this.l.Unlock()
	fmt.Fprintf(w, "| % -30s| % -10s | % -16s | % -16s | % -16s | % -16s |\n", "name", "times", "used", "max used", "min used", "avg used")
	for k, v := range this.elements {
		fmt.Fprintf(w, "| % -30s| % -10d | % -16s | % -16s | % -16s | % -16s |\n", strings.ToLower(k), v.times, utils.ToS(v.totalTick), utils.ToS(v.maxTick), utils.ToS(v.minTick), utils.ToS(time.Duration(int64(v.totalTick)/v.times)))
	}
}