// StartTimer starts timing a test. This function is called automatically
// before a benchmark starts, but it can also used to resume timing after
// a call to StopTimer.
977848
func (c *C) StartTimer() {
	if !c.timerOn {
		c.start = time.Now()
		c.timerOn = true

		runtime.ReadMemStats(&memStats)
		c.startAllocs = memStats.Mallocs
		c.startBytes = memStats.TotalAlloc
	}
}
848245
func (p *Probe) Start(interval time.Duration) {
	p.Lock()
	p.interval = interval
	p.max = interval * multiplier
	p.Unlock()
}
1089282
func (s *Stopwatch) Start() {
	s.Lock()
	defer s.Unlock()

	if !s.isRunning() {
		s.refTime = time.Now()
	}
}
646408
func (instance *ProcessInstance) StartTime() time.Time {
	return time.Now().Add(-instance.Uptime)
}
820742
func (ctx *Context) Timing(dt time.Duration, fn func(context.Context)) (err error) {
	ct, cancel := ctx.WithTimeout(dt)
	defer cancel()

	ch := make(chan error, 1) // not block tryRunTiming
	go tryRunTiming(ct, fn, ch)

	select {
	case <-ct.Done():
		err = ct.Err()
	case err = <-ch:
	}
	return
}
1374416
func StartTime(start time.Time) SpanOption {
	return func(t *Tracer, s *spanImpl) {
		s.Timestamp = start
	}
}
55099
func (fc *FakeClock) FakeTimer(d time.Duration) *FakeTimer {
	fc.Lock()
	defer fc.Unlock()

	c := make(chan time.Time, 1)
	t := &FakeTimer{
		c:     c,
		clock: fc,
		time:  fc.now.Add(d),
	}
	fc.addTimer(t)
	return t
}
520444
func (s *AssessmentRunFilter) SetStartTimeRange(v *TimestampRange) *AssessmentRunFilter {
	s.StartTimeRange = v
	return s
}
382816
func StartStatsTicker(d time.Duration) {
	ticker := time.NewTicker(d)
	go func() {
		for {
			<-ticker.C
			LogStats()
		}
	}()
}
12057
func (b *MakeyButtonDriver) Start() (err error) {
	state := 1
	go func() {
		timer := time.NewTimer(b.interval)
		timer.Stop()
		for {
			newValue, err := b.connection.DigitalRead(b.Pin())
			if err != nil {
				b.Publish(Error, err)
			} else if newValue != state && newValue != -1 {
				state = newValue
				if newValue == 0 {
					b.Active = true
					b.Publish(ButtonPush, newValue)
				} else {
					b.Active = false
					b.Publish(ButtonRelease, newValue)
				}
			}
			timer.Reset(b.interval)
			select {
			case <-timer.C:
			case <-b.halt:
				return
			}
		}
	}()
	return
}
529453
func NewTimer() *Timer {
	return &Timer{t: time.NewTimer(time.Duration(math.MaxInt64))}
}
431073
func (sit *SyncIntervalTimer) Start() {
	if sit.intervalTimer == nil {
	exitA:
		for {
			select {
			case sit.sync <- struct{}{}:
				<-sit.sync
			case <-sit.stop:
				break exitA
			}
		}
	} else {
	exitB:
		for {
			select {
			case <-sit.intervalTimer.C:
				if err := sit.f(); err != nil {
					if sit.onError != nil {
						sit.onError(err)
					}
				}
				select {
				case <-sit.stop:
					break exitB
				default:
				}
			case sit.sync <- struct{}{}:
				<-sit.sync
			case <-sit.stop:
				break exitB
			}
		}
	}
	close(sit.sync)
}
553976
func (rp *Ringpop) startTimers() {
	if rp.tickers != nil {
		return
	}
	rp.tickers = make(chan *clock.Ticker, 32) // 32 == max number of tickers

	if rp.config.MembershipChecksumStatPeriod != StatPeriodNever {
		ticker := rp.clock.Ticker(rp.config.MembershipChecksumStatPeriod)
		rp.tickers <- ticker
		go func() {
			for range ticker.C {
				rp.statter.UpdateGauge(
					rp.getStatKey("membership.checksum-periodic"),
					nil,
					int64(rp.node.GetChecksum()),
				)
			}
		}()
	}

	if rp.config.RingChecksumStatPeriod != StatPeriodNever {
		ticker := rp.clock.Ticker(rp.config.RingChecksumStatPeriod)
		rp.tickers <- ticker
		go func() {
			for range ticker.C {
				rp.statter.UpdateGauge(
					rp.getStatKey("ring.checksum-periodic"),
					nil,
					int64(rp.ring.Checksum()),
				)

				// emit all named checksums as well
				for name, checksum := range rp.ring.Checksums() {
					rp.statter.UpdateGauge(
						rp.getStatKey("ring.checksums-periodic."+name),
						nil,
						int64(checksum),
					)
				}
			}
		}()
	}
}
1159839
func (l *TimeLimiter) wait(now time.Time) time.Duration {

	// if we passed the window, reset and start over
	// if clock is adjusted backwards, best we can do is also just reset and start over
	if now.After(l.next) || now.Before(l.since) {
		l.timeSpent = 0
		l.since = now
		l.next = now.Add(l.window)
		return 0
	}
	if l.timeSpent < l.limit {
		return 0
	}

	// here we know that:
	// since <= now <= next
	// timespent >= limit
	timeToPass := time.Duration(float64(l.timeSpent) * l.factor)
	timePassed := now.Sub(l.since)

	// not sure if this should happen, but let's be safe anyway
	if timePassed > timeToPass {
		return 0
	}
	return timeToPass - timePassed
}
948521
func stoppedTimer() *time.Timer {
	timer := time.NewTimer(0)
	if !timer.Stop() {
		<-timer.C
	}
	return timer
}
265389
func resetTimer(t *time.Timer, d time.Duration) {
	t.Stop()
	// Very likely this doesn't actually work if we are already
	// selecting on t.C.  However we've stopped the original timer
	// so won't break transfers but may not time them out :-(
	*t = *time.NewTimer(d)
}
815851
func StartTimeFilter(startTime time.Time) Filter {
	return Param("start", strconv.FormatInt(ToUnixMilli(startTime), 10))
}