// DurationFromProto converts a protobuf Duration to a go Duration.
493830
func DurationFromProto(duration *google_duration.Duration) time.Duration {
	if duration == nil {
		return 0
	}
	return time.Duration((duration.Seconds * int64(time.Second)) + int64(duration.Nanos))
}
814488
func NowPlusDuration(duration time.Duration) FieldFormatterFunc {
	return func(value interface{}, op FieldOperation) (interface{}, error) {
		if op == PersistOperation {
			if duration != 0 {
				return time.Now().Add(duration), nil
			}
		}

		return value, nil
	}
}
348710
func (f *Frame) Duration() time.Duration {
	if !f.Header.IsValid() {
		return 0
	}
	ms := (1000 / float64(f.Header.SampleRate())) * float64(f.Header.Samples())
	dur := time.Duration(int(float64(time.Millisecond) * ms))
	if dur < 0 {
		// we have bad data, let's ignore it
		dur = 0
	}
	return dur
}
33814
func (a Accuracy) Duration() time.Duration {
	return 0 +
		time.Duration(a.Seconds)*time.Second +
		time.Duration(a.Millis)*time.Millisecond +
		time.Duration(a.Micros)*time.Microsecond
}
1278635
func (c *client) Duration(key string, fallback time.Duration) time.Duration {
	if d, err := time.ParseDuration(c.Getenv(key)); err == nil {
		return d
	}

	return fallback
}
855796
func (m *Time) ProtoTime() *ProtoTime {
	if m == nil {
		return &ProtoTime{}
	}
	return &ProtoTime{
		Timestamp: Timestamp{
			Seconds: m.Time.Unix(),
			Nanos:   int32(m.Time.Nanosecond()),
		},
	}
}
79533
func (m *TimerMetrics) StatusDuration(duration time.Duration) {
	if m.statusEvery == 0 {
		return
	}

	m.Lock()
	m.position++
	var looped bool
	if m.position > m.statusEvery {
		// loop back around
		looped = true
		m.position = 1
	}
	if m.position > len(m.timings) {
		m.timings = append(m.timings, duration)
	} else {
		m.timings[m.position-1] = duration
	}

	if !looped {
		m.Unlock()
		return
	}

	stats := m.getStats()
	m.Unlock()

	log.Printf("%s", stats)
}
32959
func (_m *Statter) TimingDuration(_a0 string, _a1 time.Duration, _a2 float32) error {
	ret := _m.Called(_a0, _a1, _a2)

	var r0 error
	if rf, ok := ret.Get(0).(func(string, time.Duration, float32) error); ok {
		r0 = rf(_a0, _a1, _a2)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
800624
func (c *Client) Duration(name string, duration time.Duration) error {
	return c.send(name, 1, "%d|ms", millisecond(duration))
}
2488
func durationToTimespec(d time.Duration) unix.Timespec {
	return unix.NsecToTimespec(d.Nanoseconds())
}
50313
func (t ntpTimeShort) Duration() time.Duration {
	t64 := uint64(t)
	sec := (t64 >> 16) * nanoPerSec
	frac := (t64 & 0xffff) * nanoPerSec >> 16
	return time.Duration(sec + frac)
}
736339
func (t *SimpleTrack) TimeDuration() time.Duration {
	return time.Duration(t.Duration) * time.Millisecond
}
492062
func (t *Track) Duration() time.Duration {
	ms := C.sp_track_duration(t.sp_track)
	return time.Duration(ms) * time.Millisecond
}
123189
func (c *Distconf) Duration(key string, defaultVal time.Duration) *Duration {
	c.grabInfo(key)
	s := &durationConf{
		defaultVal: defaultVal,
		Duration: Duration{
			currentVal: defaultVal.Nanoseconds(),
		},
		logger: log.NewContext(c.Logger).With(logkey.DistconfKey, key),
	}
	// Note: in race conditions 's' may not be the thing actually returned
	ret, okCast := c.createOrGet(key, s).(*durationConf)
	if !okCast {
		c.Logger.Log(logkey.DistconfKey, key, "Registering key with multiple types!  FIX ME!!!!")
		return nil
	}
	return &ret.Duration
}
1347466
func (p *parserMixin) DurationList() (target *[]time.Duration) {
	target = new([]time.Duration)
	p.DurationListVar(target)
	return
}
65326
func HistogramFromProto(protoHg *tipb.Histogram) *Histogram {
	tp := types.NewFieldType(mysql.TypeBlob)
	hg := NewHistogram(0, protoHg.Ndv, 0, 0, tp, len(protoHg.Buckets), 0)
	for _, bucket := range protoHg.Buckets {
		lower, upper := types.NewBytesDatum(bucket.LowerBound), types.NewBytesDatum(bucket.UpperBound)
		hg.AppendBucket(&lower, &upper, bucket.Count, bucket.Repeats)
	}
	return hg
}
772389
func Duration(p *durpb.Duration) (time.Duration, error) {
	if err := validateDuration(p); err != nil {
		return 0, err
	}
	d := time.Duration(p.Seconds) * time.Second
	if int64(d/time.Second) != p.Seconds {
		return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
	}
	if p.Nanos != 0 {
		d += time.Duration(p.Nanos) * time.Nanosecond
		if (d < 0) != (p.Nanos < 0) {
			return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
		}
	}
	return d, nil
}