// Perf returns a channel of Performance for monitoring the training.
177228
func (t *Trainer) Perf() <-chan Performance {
	if t.perf == nil {
		t.perf = make(chan Performance)
	}
	return t.perf
}
59131
func GetPerformance(path string) Performance {
	perf := Performance{}
	write, read, err := doPerfMeasure(path)
	if err != nil {
		perf.Error = err.Error()
		return perf
	}
	perf.WriteSpeed = write
	perf.ReadSpeed = read
	return perf
}
903032
func (m *Manager) CounterInfo(ctx context.Context) ([]types.PerfCounterInfo, error) {
	m.pm.Lock()
	defer m.pm.Unlock()

	if len(m.pm.PerfCounter) == 0 {
		err := m.Properties(ctx, m.Reference(), []string{"perfCounter"}, m.pm.PerformanceManager)
		if err != nil {
			return nil, err
		}
	}

	return m.pm.PerfCounter, nil
}
113601
func (e *Ethtool) PermAddr(intf string) (string, error) {
	permAddr, err := e.getPermAddr(intf)
	if err != nil {
		return "", err
	}

	if permAddr.data[0] == 0 && permAddr.data[1] == 0 &&
		permAddr.data[2] == 0 && permAddr.data[3] == 0 &&
		permAddr.data[4] == 0 && permAddr.data[5] == 0 {
		return "", nil
	}

	return fmt.Sprintf("%x:%x:%x:%x:%x:%x",
		permAddr.data[0:1],
		permAddr.data[1:2],
		permAddr.data[2:3],
		permAddr.data[3:4],
		permAddr.data[4:5],
		permAddr.data[5:6],
	), nil
}
1066660
func (n *NewTeam) GetPermission() string {
	if n == nil || n.Permission == nil {
		return ""
	}
	return *n.Permission
}
227801
func doPerfMeasure(fsPath string) (write, read float64, err error) {
	var count int
	var totalWriteElapsed time.Duration
	var totalReadElapsed time.Duration

	defer os.RemoveAll(fsPath)

	randBuf := make([]byte, randBufSize)
	rand.Read(randBuf)
	buf := bytes.Repeat(randBuf, randParts)

	// create the enclosing directory
	err = os.MkdirAll(fsPath, 0777)
	if err != nil {
		return 0, 0, err
	}

	for count = 1; count <= iterations; count++ {
		fsTempObjPath := path.Join(fsPath, strconv.Itoa(count))

		// Write performance calculation
		writeStart := time.Now()
		n, err := writeFile(fsTempObjPath, buf)

		if err != nil {
			return 0, 0, err
		}
		if n != fileSize {
			return 0, 0, errors.New("Could not write temporary data to disk")
		}

		writeElapsed := time.Since(writeStart)
		totalWriteElapsed += writeElapsed

		// Read performance calculation
		readStart := time.Now()
		n, err = readFile(fsTempObjPath, buf)

		if err != nil {
			return 0, 0, err
		}
		if n != fileSize {
			return 0, 0, errors.New("Could not read temporary data from disk")
		}

		readElapsed := time.Since(readStart)
		totalReadElapsed += readElapsed
	}
	// Average time spent = total time elapsed / number of writes
	avgWriteTime := totalWriteElapsed.Seconds() / float64(count)
	// Write perf = fileSize (in Bytes) / average time spent writing (in seconds)
	write = fileSize / avgWriteTime

	// Average time spent = total time elapsed / number of writes
	avgReadTime := totalReadElapsed.Seconds() / float64(count)
	// read perf = fileSize (in Bytes) / average time spent reading (in seconds)
	read = fileSize / avgReadTime

	return write, read, nil
}
832720
func (pset *Permset) ClearPerms() error {
	rv, _ := C.acl_clear_perms(pset.p)
	if rv < 0 {
		return fmt.Errorf("unable to clear perms")
	}
	return nil
}
38955
func (o *IKEGatewayConnection) AssignPerformanceMonitors(children PerformanceMonitorsList) *bambou.Error {

	list := []bambou.Identifiable{}
	for _, c := range children {
		list = append(list, c)
	}

	return bambou.CurrentSession().AssignChildren(o, list, PerformanceMonitorIdentity)
}
274109
func (b *BinningFilter) Train() error {

	as := b.getAttributeSpecs()
	// Set up the AttributeSpecs, and values
	for attr := range b.attrs {
		if !b.attrs[attr] {
			continue
		}
		b.minVals[attr] = float64(math.Inf(1))
		b.maxVals[attr] = float64(math.Inf(-1))
	}

	err := b.train.MapOverRows(as, func(row [][]byte, rowNo int) (bool, error) {
		for i, a := range row {
			attr := as[i].GetAttribute()
			attrf := attr.(*base.FloatAttribute)
			val := float64(attrf.GetFloatFromSysVal(a))
			if val > b.maxVals[attr] {
				b.maxVals[attr] = val
			}
			if val < b.minVals[attr] {
				b.minVals[attr] = val
			}
		}
		return true, nil
	})

	if err != nil {
		return fmt.Errorf("Training error: %s", err)
	}
	b.trained = true
	return nil
}
199238
func SamplingPercent(p int) TracerOption {
	if p < 0 || p > 100 {
		panic("sampling rate must be between 0 and 100")
	}
	return func(o *tracerOptions) *tracerOptions {
		o.samplingPercent = p
		return o
	}
}
729062
func PerfEventFromMemory(page *PerfEventMmapPage, buf []byte) *PerfEvent {
	pagesize := os.Getpagesize()
	e := &PerfEvent{
		cpu:      1,
		pagesize: pagesize,
		npages:   int(page.DataSize) / pagesize,
		data:     buf,
	}

	e.allocateBuffers()
	return e
}
268239
func (s *DBClusterSnapshot) SetPercentProgress(v int64) *DBClusterSnapshot {
	s.PercentProgress = &v
	return s
}
1250680
func (p *PerfEventMmapPage) Decode(reader io.ReadSeeker) error {
	return decode(p, reader)
}
841916
func (app *App) CacheFor(handler interface{}, ttl time.Duration) func(ctx *Context) {
	opts := app.getCacheOpts()

	opts.TTL = ttl
	return app.Cache(handler, opts)
}
1201640
func (c *CommitsComparison) GetPermalinkURL() string {
	if c == nil || c.PermalinkURL == nil {
		return ""
	}
	return *c.PermalinkURL
}
427316
func Perm(n int) []int {
	rng.Lock()
	defer rng.Unlock()
	return rng.rand.Perm(n)
}
432952
func createPerfSchemaTable(meta *model.TableInfo) *perfSchemaTable {
	columns := make([]*table.Column, 0, len(meta.Columns))
	for _, colInfo := range meta.Columns {
		col := table.ToColumn(colInfo)
		columns = append(columns, col)
	}
	t := &perfSchemaTable{
		meta: meta,
		cols: columns,
	}
	return t
}