// Duration calculates the time duration of this frame based on the samplerate and number of samples
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
}
831014
func Duration(input interface{}) (output time.Duration, err error) {
	switch castValue := input.(type) {
	case string:
		output, err = time.ParseDuration(castValue)
		if err != nil {
			outputInt, errCast := Int(castValue)
			if errCast != nil {
				err = NewCastError("Could not convert to time.Duration")
				return
			}
			output = time.Duration(int(outputInt))
		}
		return
	case time.Duration:
		output = castValue
		return
	default:
		outputInt, errCast := Int(castValue)
		if errCast == nil {
			output = time.Duration(int(outputInt))
			return
		}
		err = NewCastError("Could not convert to time.Duration")
	}
	return
}
153161
func (j *Job) Duration() time.Duration {
	if j.Finished().IsZero() {
		return 0 * time.Second
	}
	return j.Finished().Sub(j.Started())
}
1097333
func (c *Client) Timing(name string, value time.Duration, tags []string, rate float64) error {
	return c.TimeInMilliseconds(name, value.Seconds()*1000, tags, rate)
}
369774
func (c *Parser) Duration() (time.Duration, error) {
	if c == nil {
		return 0, errors.New("can't calculate the duration of a nil pointer")
	}
	if c.ID == [4]byte{} || c.AvgBytesPerSec == 0 {
		err := c.Parse()
		if err != nil {
			return 0, nil
		}
	}
	switch c.Format {
	case WavFormatID:
		return c.wavDuration()
	default:
		return 0, ErrFmtNotSupported
	}
}
326740
func (c *statsClient) Timing(name string, value time.Duration, rate float64) {
	if err := c.client.Timing(prefix+name, value, c.tags, rate); err != nil {
		c.logger.Printf("statsd.StatsClient.Timing error: %s", err)
	}
}
1138998
func (p *parserMixin) DurationVar(target *time.Duration) {
	p.SetValue(newDurationValue(target))
}
528223
func (s *Stream) Time() time.Duration {
	return duration(C.Pa_GetStreamTime(s.paStream))
}
746635
func (s MultiSender) Timing(stat string, duration time.Duration, tags ...string) {
	for _, ss := range s {
		ss.Timing(stat, duration, tags...)
	}
}
221200
func (c *Context) Timing(sampleRate float32, bucket string, d ...time.Duration) {
	if rand.Float32() > sampleRate {
		return
	}

	for _, dur := range d {
		c.Log(Data{"metric": bucket, "timing": int64(dur / time.Millisecond)})
	}
}
201204
func Timing(name string, value time.Duration, resolution time.Duration, tags map[string]string, opts ...SampleOption) *SSFSample {
	time := float32(value / resolution)
	return Histogram(name, time, tags, append(opts, TimeUnit(resolution))...)
}
165325
func (sr SampleRate) D(n int) time.Duration {
	return time.Second * time.Duration(n) / time.Duration(sr)
}
1027905
func toSeconds(duration time.Duration) time.Duration {
	seconds := duration.Nanoseconds() / nanosecondsPerSecond
	nanoseconds := seconds * nanosecondsPerSecond
	return time.Duration(nanoseconds)
}
1277730
func Duration(name rune, value time.Duration, helpvalue ...string) *time.Duration {
	CommandLine.FlagLong(&value, "", name, helpvalue...)
	return &value
}
256331
func (xs *xstats) Timing(stat string, duration time.Duration, tags ...string) {
	if xs.s == nil {
		return
	}
	tags = append(tags, xs.tags...)
	xs.s.Timing(xs.prefix+stat, duration, tags...)
}
1033879
func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration {
	p := new(time.Duration)
	f.DurationVar(p, name, value, usage)
	return p
}
525585
func Duration(name string, value time.Duration, usage string) *time.Duration {
	return CommandLine.Duration(name, value, usage)
}