// Measure returns a bounds box of the series.
330719
func (as AnnotationSeries) Measure(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) Box {
	box := Box{
		Top:    math.MaxInt32,
		Left:   math.MaxInt32,
		Right:  0,
		Bottom: 0,
	}
	if as.Style.IsZero() || as.Style.Show {
		seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
		for _, a := range as.Annotations {
			style := a.Style.InheritFrom(seriesStyle)
			lx := canvasBox.Left + xrange.Translate(a.XValue)
			ly := canvasBox.Bottom - yrange.Translate(a.YValue)
			ab := Draw.MeasureAnnotation(r, canvasBox, style, lx, ly, a.Label)
			box.Top = util.Math.MinInt(box.Top, ab.Top)
			box.Left = util.Math.MinInt(box.Left, ab.Left)
			box.Right = util.Math.MaxInt(box.Right, ab.Right)
			box.Bottom = util.Math.MaxInt(box.Bottom, ab.Bottom)
		}
	}
	return box
}
848928
func (f *IndexFile) MeasurementN() (n uint64) {
	mitr := f.mblk.Iterator()
	for me := mitr.Next(); me != nil; me = mitr.Next() {
		n++
	}
	return n
}
864777
func (s *Store) MeasureSince(key string, start time.Time) {
	s.mu.Lock()
	s.metrics[key] = append(s.metrics[key], time.Since(start))
	s.mu.Unlock()
}
1155520
func (ci CellID) boundST() r2.Rect {
	s := ci.sizeST(ci.Level())
	return r2.RectFromCenterSize(ci.centerST(), r2.Point{s, s})
}
298153
func (b Box) Fit(other Box) Box {
	ba := b.Aspect()
	oa := other.Aspect()

	if oa == ba {
		return b.Clone()
	}

	bw, bh := float64(b.Width()), float64(b.Height())
	bw2 := int(bw) >> 1
	bh2 := int(bh) >> 1
	if oa > ba { // ex. 16:9 vs. 4:3
		var noh2 int
		if oa > 1.0 {
			noh2 = int(bw/oa) >> 1
		} else {
			noh2 = int(bh*oa) >> 1
		}
		return Box{
			Top:    (b.Top + bh2) - noh2,
			Left:   b.Left,
			Right:  b.Right,
			Bottom: (b.Top + bh2) + noh2,
		}
	}
	var now2 int
	if oa > 1.0 {
		now2 = int(bh/oa) >> 1
	} else {
		now2 = int(bw*oa) >> 1
	}
	return Box{
		Top:    b.Top,
		Left:   (b.Left + bw2) - now2,
		Right:  (b.Left + bw2) + now2,
		Bottom: b.Bottom,
	}
}
570533
func (b Box) Width() int {
	return util.Math.AbsInt(b.Right - b.Left)
}
364863
func (t TimeUnit) Count(c CountUnit, dimension int8) MetricUnit {
	return (&metricUnit{uint32(t)}).Count(c, dimension)
}
918965
func (p *Path) Measure(point *Point) float64 {
	minDistance := math.Inf(1)
	measure := math.Inf(-1)
	sum := 0.0

	seg := &Line{}
	for i := 0; i < len(p.PointSet)-1; i++ {
		seg.a = p.PointSet[i]
		seg.b = p.PointSet[i+1]
		distanceToLine := seg.SquaredDistanceFrom(point)
		if distanceToLine < minDistance {
			minDistance = distanceToLine
			measure = sum + seg.Measure(point)
		}
		sum += seg.Distance()
	}
	return measure
}
776217
func (m mathUtil) Mean(values ...float64) float64 {
	return m.Sum(values...) / float64(len(values))
}
530906
func (lrs LinearRegressionSeries) Len() int {
	return util.Math.MinInt(lrs.GetLimit(), lrs.InnerSeries.Len()-lrs.GetOffset())
}
427309
func (bb BBox) Bound() orb.Bound {
	if !bb.Valid() {
		return orb.Bound{}
	}

	mid := len(bb) / 2

	return orb.Bound{
		Min: orb.Point{bb[0], bb[1]},
		Max: orb.Point{bb[mid], bb[mid+1]},
	}
}
32114
func (c *gaugesWithMultiLabelsCollector) Collect(ch chan<- prometheus.Metric) {
	for lvs, val := range c.gml.Counts() {
		labelValues := strings.Split(lvs, ".")
		value := float64(val)
		ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, value, labelValues...)
	}
}
794997
func (g *geom0) Bounds() *Bounds {
	return NewBounds(g.layout).extendFlatCoords(g.flatCoords, 0, len(g.flatCoords), g.stride)
}
968925
func means(X *mat.Dense) []float64 {
	n_obs, n_feats := X.Dims()
	var result []float64
	for j := 0; j < n_feats; j++ {
		sum_j := 0.0
		for i := 0; i < n_obs; i++ {
			sum_j = sum_j + X.At(i, j)
		}
		mean := (sum_j / float64(n_obs))
		result = append(result, mean)
	}
	return result
}
965667
func (d draw) BoundedSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, bbs BoundedValuesProvider, drawOffsetIndexes ...int) {
	drawOffsetIndex := 0
	if len(drawOffsetIndexes) > 0 {
		drawOffsetIndex = drawOffsetIndexes[0]
	}

	cb := canvasBox.Bottom
	cl := canvasBox.Left

	v0x, v0y1, v0y2 := bbs.GetBoundedValues(0)
	x0 := cl + xrange.Translate(v0x)
	y0 := cb - yrange.Translate(v0y1)

	var vx, vy1, vy2 float64
	var x, y int

	xvalues := make([]float64, bbs.Len())
	xvalues[0] = v0x
	y2values := make([]float64, bbs.Len())
	y2values[0] = v0y2

	style.GetFillAndStrokeOptions().WriteToRenderer(r)
	r.MoveTo(x0, y0)
	for i := 1; i < bbs.Len(); i++ {
		vx, vy1, vy2 = bbs.GetBoundedValues(i)

		xvalues[i] = vx
		y2values[i] = vy2

		x = cl + xrange.Translate(vx)
		y = cb - yrange.Translate(vy1)
		if i > drawOffsetIndex {
			r.LineTo(x, y)
		} else {
			r.MoveTo(x, y)
		}
	}
	y = cb - yrange.Translate(vy2)
	r.LineTo(x, y)
	for i := bbs.Len() - 1; i >= drawOffsetIndex; i-- {
		vx, vy2 = xvalues[i], y2values[i]
		x = cl + xrange.Translate(vx)
		y = cb - yrange.Translate(vy2)
		r.LineTo(x, y)
	}
	r.Close()
	r.FillStroke()
}
912399
func (pm *ProtocolManager) measure(setup *benchmarkSetup, count int) error {
	clientPipe, serverPipe := p2p.MsgPipe()
	clientMeteredPipe := &meteredPipe{rw: clientPipe}
	serverMeteredPipe := &meteredPipe{rw: serverPipe}
	var id enode.ID
	rand.Read(id[:])
	clientPeer := pm.newPeer(lpv2, NetworkId, p2p.NewPeer(id, "client", nil), clientMeteredPipe)
	serverPeer := pm.newPeer(lpv2, NetworkId, p2p.NewPeer(id, "server", nil), serverMeteredPipe)
	serverPeer.sendQueue = newExecQueue(count)
	serverPeer.announceType = announceTypeNone
	serverPeer.fcCosts = make(requestCostTable)
	c := &requestCosts{}
	for code := range requests {
		serverPeer.fcCosts[code] = c
	}
	serverPeer.fcParams = flowcontrol.ServerParams{BufLimit: 1, MinRecharge: 1}
	serverPeer.fcClient = flowcontrol.NewClientNode(pm.server.fcManager, serverPeer.fcParams)
	defer serverPeer.fcClient.Disconnect()

	if err := setup.req.init(pm, count); err != nil {
		return err
	}

	errCh := make(chan error, 10)
	start := mclock.Now()

	go func() {
		for i := 0; i < count; i++ {
			if err := setup.req.request(clientPeer, i); err != nil {
				errCh <- err
				return
			}
		}
	}()
	go func() {
		for i := 0; i < count; i++ {
			if err := pm.handleMsg(serverPeer); err != nil {
				errCh <- err
				return
			}
		}
	}()
	go func() {
		for i := 0; i < count; i++ {
			msg, err := clientPipe.ReadMsg()
			if err != nil {
				errCh <- err
				return
			}
			var i interface{}
			msg.Decode(&i)
		}
		// at this point we can be sure that the other two
		// goroutines finished successfully too
		close(errCh)
	}()
	select {
	case err := <-errCh:
		if err != nil {
			return err
		}
	case <-pm.quitSync:
		clientPipe.Close()
		serverPipe.Close()
		return fmt.Errorf("Benchmark cancelled")
	}

	setup.totalTime += time.Duration(mclock.Now() - start)
	setup.totalCount += count
	setup.maxInSize = clientMeteredPipe.maxSize
	setup.maxOutSize = serverMeteredPipe.maxSize
	clientPipe.Close()
	serverPipe.Close()
	return nil
}
1204152
func (a Sources) Measurements() []*Measurement {
	mms := make([]*Measurement, 0, len(a))
	for _, src := range a {
		switch src := src.(type) {
		case *Measurement:
			mms = append(mms, src)
		case *SubQuery:
			mms = append(mms, src.Statement.Sources.Measurements()...)
		}
	}
	return mms
}