//ElapsedIn returns the elapsed time in int64
963680
func ElapsedIn(ms time.Time, diff time.Time) int64 {
	return diff.UTC().Sub(ms.UTC()).Nanoseconds() / 1e6
}
1010206
func (t ElapsedTime) MarshalBinary() ([]byte, error) {
	b := buffer.New(nil)

	unit := 10 * time.Millisecond
	// The elapsed time value is an unsigned, 16 bit integer.
	// The client uses the value 0xffff to represent any
	// elapsed time values greater than the largest time value
	// that can be represented in the Elapsed Time option.
	if max := time.Duration(math.MaxUint16) * unit; time.Duration(t) > max {
		t = ElapsedTime(max)
	}
	b.Write16(uint16(time.Duration(t) / unit))
	return b.Data(), nil
}
105720
func elapsedTime(p *process.Process) (string, error) {
	crtTime, err := p.CreateTime()
	if err != nil {
		return "", err
	}
	etime := time.Since(time.Unix(int64(crtTime/1000), 0))
	return fmtEtimeDuration(etime), nil
}
958481
func parseDeltaSeconds(v string) (DeltaSeconds, error) {
	n, err := strconv.ParseUint(v, 10, 32)
	if err != nil {
		if numError, ok := err.(*strconv.NumError); ok {
			if numError.Err == strconv.ErrRange {
				return DeltaSeconds(math.MaxInt32), nil
			}
		}
		return DeltaSeconds(-1), err
	} else {
		if n > math.MaxInt32 {
			return DeltaSeconds(math.MaxInt32), nil
		} else {
			return DeltaSeconds(n), nil
		}
	}
}
295476
func EventAddTimeout(freq int, callback EventTimeoutCallback) (int, error) {
	callbackID := registerCallbackId(callback)

	var err C.virError
	ret := C.virEventAddTimeoutWrapper((C.int)(freq), (C.int)(callbackID), &err)
	if ret == -1 {
		return 0, makeError(&err)
	}

	return int(ret), nil
}
848120
func (h *Timing) ServerResponseTime(serverResponseTime int64) *Timing {
	h.serverResponseTime = serverResponseTime
	h.serverResponseTimeSet = true
	return h
}
958487
func (c *IdleTimingConn) TimesOutIn() time.Duration {
	return c.idleTimeout - mtime.Now().Sub(mtime.Instant(atomic.LoadUint64(&c.lastActivityTime)))
}
723881
func (s *DataTransferProgress) SetElapsedTimeInSeconds(v int64) *DataTransferProgress {
	s.ElapsedTimeInSeconds = &v
	return s
}
869718
func (s *Stopwatch) ElapsedSeconds() float64 {
	s.RLock()
	defer s.RUnlock()

	return s.Elapsed().Seconds()
}
188182
func (s *CancelResizeOutput) SetElapsedTimeInSeconds(v int64) *CancelResizeOutput {
	s.ElapsedTimeInSeconds = &v
	return s
}
542708
func (r Rect) ResizedMin(size Vec) Rect {
	return Rect{
		Min: r.Min,
		Max: r.Min.Add(size),
	}
}
147038
func (s Stats) FillIn() Stats {
	fillIn(reflect.ValueOf(&s).Elem())
	return s
}
719810
func WithTimeAndRand() {
	var (
		b [4]byte
		u int64
	)

	tryReadRandom(b[:])

	// Set higher 32 bits, bottom 32 will be set with nanos
	u |= (int64(b[0]) << 56) | (int64(b[1]) << 48) | (int64(b[2]) << 40) | (int64(b[3]) << 32)

	rand.Seed(u ^ time.Now().UnixNano())
}
467034
func NormaliseDomain(low, high []byte) ([]byte, []byte) {
	if len(low) == 0 {
		low = []byte{}
	}
	return low, high
}
974056
func (t token) willExpireIn(d time.Duration) bool {
	s, err := strconv.Atoi(t.ExpiresOn)
	if err != nil {
		s = -3600
	}
	expiryTime := expirationBase.Add(time.Duration(s) * time.Second).UTC()

	return !expiryTime.After(time.Now().Add(d))
}
1068500
func (t *AccessToken) ExpiresIn() time.Duration {
	if t.ExpiresAt == nil {
		return 0
	}

	return t.ExpiresAt.Sub(time.Now())
}
1166474
func (h *Head) initTime(t int64) (initialized bool) {
	if !atomic.CompareAndSwapInt64(&h.minTime, math.MaxInt64, t) {
		return false
	}
	// Ensure that max time is initialized to at least the min time we just set.
	// Concurrent appenders may already have set it to a higher value.
	atomic.CompareAndSwapInt64(&h.maxTime, math.MinInt64, t)

	return true
}