// BandwidthFromDelta calculates the bandwidth from a number of bytes and a time delta
967836
func BandwidthFromDelta(bytes protocol.ByteCount, delta time.Duration) Bandwidth {
	return Bandwidth(bytes) * Bandwidth(time.Second) / Bandwidth(delta) * BytesPerSecond
}
425900
func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
	startingDeltaBound := math.Pow(10.0, 10.0)
	for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
		if delta > cursor {
			return cursor / 10.0
		}
	}

	return 0.0
}
817794
func (c *Clock) Delta() float32 {
	return float32(float64(c.deltaStamp) / float64(secondsInNano))
}
1248011
func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {
	r, err := base.Reader()
	if err != nil {
		return err
	}

	w, err := target.Writer()
	if err != nil {
		return err
	}

	src, err := ioutil.ReadAll(r)
	if err != nil {
		return err
	}

	dst, err := PatchDelta(src, delta)
	if err != nil {
		return err
	}

	target.SetSize(int64(len(dst)))

	_, err = w.Write(dst)
	return err
}
340711
func (r Billing_Item) GetBandwidthAllocation() (resp datatypes.Network_Bandwidth_Version1_Allocation, err error) {
	err = r.Session.DoRequest("SoftLayer_Billing_Item", "getBandwidthAllocation", nil, &r.Options, &resp)
	return
}
633860
func InlineData(p *params) {
	p.ext4opts = append(p.ext4opts, compactext4.InlineData)
}
121554
func (f *inFlow) onData(n uint32) error {
	f.mu.Lock()
	f.pendingData += n
	if f.pendingData+f.pendingUpdate > f.limit+f.delta {
		limit := f.limit
		rcvd := f.pendingData + f.pendingUpdate
		f.mu.Unlock()
		return fmt.Errorf("received %d-bytes data exceeding the limit %d bytes", rcvd, limit)
	}
	f.mu.Unlock()
	return nil
}
369254
func GetPvtdataStoreCollElgProcDbBatchesInterval() int {
	collElgProcDbBatchesInterval := viper.GetInt(confCollElgProcDbBatchesInterval.Name)
	if collElgProcDbBatchesInterval <= 0 {
		collElgProcDbBatchesInterval = confCollElgProcDbBatchesInterval.DefaultVal
	}
	return collElgProcDbBatchesInterval
}
1272184
func (r *Range) fDelta(delta, mindelta float64) float64 {
	if r.Log {
		return 10
	}

	// Set up nice tic delta of the form 1,2,5 * 10^n
	// TODO: deltas of 25 and 250 would be suitable too...
	de := math.Pow10(int(math.Floor(math.Log10(delta))))
	f := delta / de
	switch {
	case f < 2:
		f = 1
	case f < 4:
		f = 2
	case f < 9:
		f = 5
	default:
		f = 1
		de *= 10
	}
	delta = f * de
	if delta < mindelta {
		DebugLogger.Printf("Redoing delta: %g < %g", delta, mindelta)
		// recalculate tic delta
		switch f {
		case 1, 5:
			delta *= 2
		case 2:
			delta *= 2.5
		default:
			fmt.Printf("Oooops. Strange f: %g\n", f)
		}
	}
	return delta
}
1032452
func (p *PrefixLengthCounter) ToBPFData() (s6, s4 []int) {
	p.RLock()
	defer p.RUnlock()

	return p.v6.ToBPFData(), p.v4.ToBPFData()
}
384097
func (options *Options) FnData(data *DataFrame) string {
	return options.evalBlock(nil, data, nil)
}
48174
func needDumpStatsDelta(h *Handle, id int64, item variable.TableDelta, currentTime time.Time) bool {
	if item.InitTime.IsZero() {
		item.InitTime = currentTime
	}
	tbl, ok := h.StatsCache.Load().(StatsCache)[id]
	if !ok {
		// No need to dump if the stats is invalid.
		return false
	}
	if currentTime.Sub(item.InitTime) > dumpStatsMaxDuration {
		// Dump the stats to kv at least once an hour.
		return true
	}
	if tbl.Count == 0 || float64(item.Count)/float64(tbl.Count) > DumpStatsDeltaRatio {
		// Dump the stats when there are many modifications.
		return true
	}
	return false
}
437592
func (a *GetHistogramsArgs) SetDelta(delta bool) *GetHistogramsArgs {
	a.Delta = &delta
	return a
}
535101
func (c *tabletStatsCache) aggregatedData(keyspace, cell, selectedType, selectedMetric string, metricFunc func(stats *discovery.TabletStats) float64) ([][]float64, [][]*topodatapb.TabletAlias, yLabel) {
	shards := c.shards(keyspace)
	tabletTypes := c.tabletTypesLocked(keyspace, cell, selectedType)

	var cellData [][]float64
	dataRow := make([]float64, len(shards))
	// This loop goes through each shard in the (keyspace-cell) combination.
	for shardIndex, shard := range shards {
		var sum, count float64
		hasTablets := false
		unhealthyFound := false
		// Going through all the types of tablets and aggregating their information.
		for _, tabletType := range tabletTypes {
			tablets, ok := c.statuses[keyspace][shard][cell][tabletType]
			if !ok {
				continue
			}
			for _, tablet := range tablets {
				hasTablets = true
				// If even one tablet is unhealthy then the entire group becomes unhealthy.
				metricVal := metricFunc(tablet)
				if (selectedMetric == "health" && metricVal == tabletUnhealthy) ||
					(selectedMetric == "lag" && metricVal > lagThresholdUnhealthy) {
					sum = metricVal
					count = 1
					unhealthyFound = true
					break
				}
				sum += metricVal
				count++
			}
			if unhealthyFound {
				break
			}
		}
		if hasTablets {
			dataRow[shardIndex] = (sum / count)
		} else {
			dataRow[shardIndex] = tabletMissing
		}
	}
	cellData = append(cellData, dataRow)
	cellLabel := yLabel{
		CellLabel: label{Name: cell, Rowspan: 1},
	}

	return cellData, nil, cellLabel
}
161743
func (c *Context) DataFromReader(code int, contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string) {
	c.Render(code, render.Reader{
		Headers:       extraHeaders,
		ContentType:   contentType,
		ContentLength: contentLength,
		Reader:        reader,
	})
}
11568
func GetBandwidth(query map[string]string, lastModifiedSince string) (*Bandwidth, string, error) {
	bandwidth := new(Bandwidth)

	if lastModified, err := executeRequest("bandwidth", query, lastModifiedSince, &bandwidth); err != nil {
		return nil, "", err
	} else {
		return bandwidth, lastModified, nil
	}
}
1339159
func (c *cubicSender) BandwidthEstimate() Bandwidth {
	srtt := c.rttStats.SmoothedRTT()
	if srtt == 0 {
		// If we haven't measured an rtt, the bandwidth estimate is unknown.
		return 0
	}
	return BandwidthFromDelta(c.GetCongestionWindow(), srtt)
}