// Timer returns a timer sub-logger.
8643
func (l *Logger) Timer() *Log {
	return &Log{
		Package: l.Name,
		Level:   "TIMER",
		Time:    Now(),
	}
}
1249501
func (c *Context) Timer(data Data) *Timer {
	context := c.New(data)
	context.Log(Data{"at": "start"})
	return &Timer{
		Started:  time.Now(),
		TimeUnit: context.TimeUnit,
		context:  context,
		_statter: c._statter.dup(),
	}
}
1363821
func LogHandler() func(http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			ptw := passThroughResponseWriter{200, w}
			start := time.Now()
			next.ServeHTTP(&ptw, r)
			xlog.FromContext(r.Context()).Info(http.StatusText(ptw.StatusCode), xlog.F{
				"duration": time.Now().Sub(start).String(),
				"status":   ptw.StatusCode,
			})
		})
	}
}
423141
func (r Range) Duration() time.Duration {
	return r.End.Sub(r.Start)
}
943490
func (l *Logger) Log(level LogLevel, v ...interface{}) {
	if l.getLevel() <= level {
		l.getHandler().Log(l.name, level, fmt.Sprint(v...), 1)
	}
}
69572
func clearTimer(tp **time.Timer) {
	if t := *tp; t != nil {
		t.Stop()
		*tp = nil
	}
}
553866
func deltimer(t *Timer) bool {
	// Dereference t so that any panic happens before the lock is held.
	// Discard result, because t might be moving in the heap.
	_ = t.i

	timers.lock.Lock()
	// t may not be registered anymore and may have
	// a bogus i (typically 0, if generated by Go).
	// Verify it before proceeding.
	i := t.i
	last := len(timers.t) - 1
	if i < 0 || i > last || timers.t[i] != t {
		timers.lock.Unlock()
		return false
	}
	if i != last {
		timers.t[i] = timers.t[last]
		timers.t[i].i = i
	}
	timers.t[last] = nil
	timers.t = timers.t[:last]
	if i != last {
		siftupTimer(i)
		siftdownTimer(i)
	}
	timers.lock.Unlock()
	return true
}
1150039
func (r *Reader) Duration(name string) time.Duration {
	return r.DurationDefault(name, 0)
}
726950
func (m *Metrics) Stop(timer *MetricTimer) {
	if timer != nil {
		timer.Timer.UpdateSince(timer.Time)
	}
}
948521
func stoppedTimer() *time.Timer {
	timer := time.NewTimer(0)
	if !timer.Stop() {
		<-timer.C
	}
	return timer
}
855875
func (tt *TimerToken) Stop() time.Duration {
	duration := time.Since(tt.Start)
	tt.MetricSystem.Histogram(tt.Name, float64(duration.Nanoseconds()))
	return duration
}
612393
func EventRemoveTimeout(timer int) error {
	var err C.virError
	ret := C.virEventRemoveTimeoutWrapper((C.int)(timer), &err)
	if ret < 0 {
		return makeError(&err)
	}

	return nil
}
642992
func Duration(key string, t time.Duration) log.Field {
	return log.String(key, fmt.Sprint(t))
}
415075
func (tm *Timer) Trigger() {
	tm.mu.Lock()
	defer tm.mu.Unlock()
	if tm.running {
		tm.msg <- timerTrigger
	}
}
602896
func (t *Timer) Record(delta time.Duration) {
	t.hist.Observe(delta.Seconds())
}
888079
func (fc *FakeClock) Timer(d time.Duration) Timer {
	return fc.FakeTimer(d)
}
368799
func (t *FixedInterval) Start() bool {
	t.Lock()
	defer t.Unlock()

	// If the timer is already started or uninitialized return false.
	if t.running() || !t.initialized {
		return false
	}

	// Create the new timer with the delay
	t.timer = time.AfterFunc(t.GetDelay(), t.action)
	return true
}