// PowerUsage returns the power usage for this GPU and its associated circuitry
// in milliwatts. The reading is accurate to within +/- 5% of current power draw.
976970
func (d Device) PowerUsage() (uint, error) {
	if C.nvmlHandle == nil {
		return 0, errLibraryNotLoaded
	}
	var n C.uint
	r := C.nvmlDeviceGetPowerUsage(d.dev, &n)
	return uint(n), errorString(r)
}
274532
func memoryUsage(memStats *statsapi.MemoryStats) *resource.Quantity {
	if memStats == nil || memStats.WorkingSetBytes == nil {
		return &resource.Quantity{Format: resource.BinarySI}
	}
	usage := int64(*memStats.WorkingSetBytes)
	return resource.NewQuantity(usage, resource.BinarySI)
}
1058076
func (d Datacenter) PowerOnVM(ctx context.Context, vm []types.ManagedObjectReference, option ...types.BaseOptionValue) (*Task, error) {
	if d.Client().IsVC() {
		req := types.PowerOnMultiVM_Task{
			This:   d.Reference(),
			Vm:     vm,
			Option: option,
		}

		res, err := methods.PowerOnMultiVM_Task(ctx, d.c, &req)
		if err != nil {
			return nil, err
		}

		return NewTask(d.c, res.Returnval), nil
	}

	for _, ref := range vm {
		obj := NewVirtualMachine(d.Client(), ref)
		task, err := obj.PowerOn(ctx)
		if err != nil {
			return nil, err
		}

		err = task.Wait(ctx)
		if err != nil {
			// Ignore any InvalidPowerState fault, as it indicates the VM is already powered on
			if f, ok := err.(types.HasFault); ok {
				if _, ok = f.Fault().(*types.InvalidPowerState); !ok {
					return nil, err
				}
			}
		}
	}

	return nil, nil
}
1194662
func (fs *FSObjects) diskUsage(doneCh chan struct{}) {
	usageFn := func(ctx context.Context, entry string) error {
		if globalHTTPServer != nil {
			// Wait at max 1 minute for an inprogress request
			// before proceeding to count the usage.
			waitCount := 60
			// Any requests in progress, delay the usage.
			for globalHTTPServer.GetRequestCount() > 0 && waitCount > 0 {
				waitCount--
				time.Sleep(1 * time.Second)
			}
		}

		select {
		case <-doneCh:
			return errWalkAbort
		default:
			fi, err := os.Stat(entry)
			if err != nil {
				err = osErrToFSFileErr(err)
				return err
			}
			atomic.AddUint64(&fs.totalUsed, uint64(fi.Size()))
		}
		return nil
	}

	// Return this routine upon errWalkAbort, continue for any other error on purpose
	// so that we can start the routine freshly in another 12 hours.
	if err := getDiskUsage(context.Background(), fs.fsPath, usageFn); err == errWalkAbort {
		return
	}

	for {
		select {
		case <-doneCh:
			return
		case <-time.After(globalUsageCheckInterval):
			var usage uint64
			usageFn = func(ctx context.Context, entry string) error {
				if globalHTTPServer != nil {
					// Wait at max 1 minute for an inprogress request
					// before proceeding to count the usage.
					waitCount := 60
					// Any requests in progress, delay the usage.
					for globalHTTPServer.GetRequestCount() > 0 && waitCount > 0 {
						waitCount--
						time.Sleep(1 * time.Second)
					}
				}

				fi, err := os.Stat(entry)
				if err != nil {
					err = osErrToFSFileErr(err)
					return err
				}
				usage = usage + uint64(fi.Size())
				return nil
			}

			if err := getDiskUsage(context.Background(), fs.fsPath, usageFn); err != nil {
				continue
			}
			atomic.StoreUint64(&fs.totalUsed, usage)
		}
	}
}
750938
func (m *MockVolumeDriver) UsedSize(arg0 string) (uint64, error) {
	ret := m.ctrl.Call(m, "UsedSize", arg0)
	ret0, _ := ret[0].(uint64)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
854091
func TotalEnergy(buf *audio.PCMBuffer) float64 {
	var e float64
	for _, v := range buf.AsFloat64s() {
		e += v * v
	}
	return e
}
60731
func (a *Application) FatalUsage(format string, args ...interface{}) {
	a.Errorf(format, args...)
	// Force usage to go to error output.
	a.usageWriter = a.errorWriter
	a.Usage([]string{})
	a.terminate(1)
}
370036
func (s *posix) diskUsage(doneCh chan struct{}) {
	ticker := time.NewTicker(globalUsageCheckInterval)
	defer ticker.Stop()

	usageFn := func(ctx context.Context, entry string) error {
		if globalHTTPServer != nil {
			// Wait at max 1 minute for an inprogress request
			// before proceeding to count the usage.
			waitCount := 60
			// Any requests in progress, delay the usage.
			for globalHTTPServer.GetRequestCount() > 0 && waitCount > 0 {
				waitCount--
				time.Sleep(1 * time.Second)
			}
		}

		select {
		case <-doneCh:
			return errWalkAbort
		case <-s.stopUsageCh:
			return errWalkAbort
		default:
			fi, err := os.Stat(entry)
			if err != nil {
				err = osErrToFSFileErr(err)
				return err
			}
			atomic.AddUint64(&s.totalUsed, uint64(fi.Size()))
			return nil
		}
	}

	// Return this routine upon errWalkAbort, continue for any other error on purpose
	// so that we can start the routine freshly in another 12 hours.
	if err := getDiskUsage(context.Background(), s.diskPath, usageFn); err == errWalkAbort {
		return
	}

	for {
		select {
		case <-s.stopUsageCh:
			return
		case <-doneCh:
			return
		case <-time.After(globalUsageCheckInterval):
			var usage uint64
			usageFn = func(ctx context.Context, entry string) error {
				if globalHTTPServer != nil {
					// Wait at max 1 minute for an inprogress request
					// before proceeding to count the usage.
					waitCount := 60
					// Any requests in progress, delay the usage.
					for globalHTTPServer.GetRequestCount() > 0 && waitCount > 0 {
						waitCount--
						time.Sleep(1 * time.Second)
					}
				}

				select {
				case <-s.stopUsageCh:
					return errWalkAbort
				default:
					fi, err := os.Stat(entry)
					if err != nil {
						err = osErrToFSFileErr(err)
						return err
					}
					usage = usage + uint64(fi.Size())
					return nil
				}
			}

			if err := getDiskUsage(context.Background(), s.diskPath, usageFn); err != nil {
				continue
			}

			atomic.StoreUint64(&s.totalUsed, usage)
		}
	}
}
625046
func (o *Output) Used() bool {
	o.Lock()
	defer o.Unlock()
	return o.used
}
489930
func inodeUsage(fsStats *statsapi.FsStats) *resource.Quantity {
	if fsStats == nil || fsStats.InodesUsed == nil {
		return &resource.Quantity{Format: resource.DecimalSI}
	}
	usage := int64(*fsStats.InodesUsed)
	return resource.NewQuantity(usage, resource.DecimalSI)
}
538997
func (cp *Pool) InUse() int64 {
	p := cp.pool()
	if p == nil {
		return 0
	}
	return p.InUse()
}
566876
func (d *Datastore) DiskUsage() (uint64, error) {
	var duTotal uint64 = 0
	for _, d := range d.mounts {
		du, err := ds.DiskUsage(d.Datastore)
		duTotal += du
		if err != nil {
			return duTotal, err
		}
	}
	return duTotal, nil
}
771494
func (cmd *CLI) Usage() {
	if cmd.usage == nil {
		cmd.usage = cmd.DefaultUsage
	}
	cmd.usage()
}
194862
func (vc *Bucket) Power(id crypto.Address) (*big.Int, error) {
	return vc.Previous.Power(id)
}
446260
func (s *statsNotSupported) CapacityUsage(
	ID string,
) (*api.CapacityUsageResponse, error) {
	return nil, ErrNotSupported
}
574493
func DiskUsage(path string) (*resource.Quantity, error) {
	_, _, usage, _, _, _, err := FsInfo(path)
	if err != nil {
		return nil, err
	}

	used, err := resource.ParseQuantity(fmt.Sprintf("%d", usage))
	if err != nil {
		return nil, fmt.Errorf("failed to parse fs usage %d due to %v", usage, err)
	}
	used.Format = resource.BinarySI
	return &used, nil
}
809048
func (cfs *cacheFSObjects) diskUsageHigh() bool {
	di, err := disk.GetInfo(cfs.dir)
	if err != nil {
		reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", cfs.dir)
		ctx := logger.SetReqInfo(context.Background(), reqInfo)
		logger.LogIf(ctx, err)
		return true
	}
	usedPercent := (di.Total - di.Free) * 100 / di.Total
	return int(usedPercent) > cfs.maxDiskUsagePct
}