// calculateMemUsageUnixNoCache calculate memory usage of the container.
// Page cache is intentionally excluded to avoid misinterpretation of the output.
189985
func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 {
	return float64(mem.Usage - mem.Stats["cache"])
}
335422
func (cb *configBased) AllCacheMisses() uint64 {
	var total uint64
	for _, cache := range cb.metricCache {
		total += cache.allCacheMisses()
	}
	return total
}
421377
func (obj *GenericMeasure) GetMeasure(ctx context.Context) (*NxLibraryMeasureDef, error) {
	result := &struct {
		Measure *NxLibraryMeasureDef	`json:"qMeasure"`
	} {}
	err := obj.rpc(ctx, "GetMeasure", result)
	return result.Measure, err 
}
646039
func cacheSize(block uint64) uint64 {
	epoch := int(block / epochLength)
	if epoch < maxEpoch {
		return cacheSizes[epoch]
	}
	return calcCacheSize(epoch)
}
1212718
func (isi *ImageStreamImporter) calculateImageSize(ctx gocontext.Context, bs distribution.BlobStore, image *imageapi.Image) error {
	blobSet := sets.NewString()
	size := int64(0)
	for i := range image.DockerImageLayers {
		layer := &image.DockerImageLayers[i]

		if blobSet.Has(layer.Name) {
			continue
		}
		blobSet.Insert(layer.Name)

		if layerSize, ok := isi.digestToLayerSizeCache.Get(layer.Name); ok {
			layerSize := layerSize.(int64)
			layer.LayerSize = layerSize
			size += layerSize
			continue
		}

		desc, err := bs.Stat(ctx, godigest.Digest(layer.Name))
		if err != nil {
			return err
		}

		isi.digestToLayerSizeCache.Add(layer.Name, desc.Size)
		layer.LayerSize = desc.Size
		size += desc.Size
	}

	if len(image.DockerImageConfig) > 0 && !blobSet.Has(image.DockerImageMetadata.ID) {
		blobSet.Insert(image.DockerImageMetadata.ID)
		size += int64(len(image.DockerImageConfig))
	}

	image.DockerImageMetadata.Size = size
	return nil
}
851067
func hasMemoryAndCPUInstUsage(info *cadvisorapiv2.ContainerInfo) bool {
	if !info.Spec.HasCpu || !info.Spec.HasMemory {
		return false
	}
	cstat, found := latestContainerStats(info)
	if !found {
		return false
	}
	if cstat.CpuInst == nil {
		return false
	}
	return cstat.CpuInst.Usage.Total != 0 && cstat.Memory.RSS != 0
}
1238980
func (tc *TransCache) GetItemExpiryTime(chID, itmID string) (exp time.Time, ok bool) {
	tc.cacheMux.RLock()
	defer tc.cacheMux.RUnlock()
	return tc.cacheInstance(chID).GetItemExpiryTime(itmID)
}
595822
func NewPoolInfoCache(size int) (*PoolInfoCache, error) {
	if size < 2 {
		return nil, fmt.Errorf("size %d is less than 2", size)
	}
	return &PoolInfoCache{
		poolInfo:    make(map[chainhash.Hash]*apitypes.TicketPoolInfo, size),
		expireQueue: make([]chainhash.Hash, 0, size),
		maxSize:     size,
	}, nil
}
888931
func (gc *Cfg) GetVxlansInUse() (uint, string) {
	tempRm, err := resources.GetStateResourceManager()
	if err != nil {
		log.Errorf("error getting resource manager: %s", err)
		return 0, ""
	}
	ra := core.ResourceManager(tempRm)

	return ra.GetResourceList("global", resources.AutoVXLANResource)
}
624963
func (s *sticky) AllCacheHits() uint64 {
	var total uint64
	for _, cache := range s.metricCache {
		total += cache.allCacheHits()
	}
	return total
}
403132
func (apic *APICache) Utilization() float64 {
	apic.mtx.RLock()
	defer apic.mtx.RUnlock()
	return 100.0 * float64(len(apic.blockCache)) / float64(apic.capacity)
}
710980
func newCache(capacity int) *cache {
	if capacity <= 0 {
		capacity = MinCacheCapacity
	}
	return &cache{
		capacity: capacity,
		entries:  make(map[string]entry),
	}
}
666372
func NewMemory(policies Policies, namespace string) Cache {
	return &memory{
		policies: policies,
		h:        isolated.GetHash(namespace),
		data:     map[isolated.HexDigest][]byte{},
		lru:      makeLRUDict(namespace),
	}
}
946926
func (prof *Profiler) CalculateUsage(cur *structs.DevInfo) *structs.DevUsage {
	u := &structs.DevUsage{
		Timestamp:  cur.Timestamp,
		TimeDelta:  cur.Timestamp - prof.prior.Timestamp,
		Device: make([]structs.Device, len(cur.Device)),
	}
	for i := 0; i < len(cur.Device); i++ {
		u.Device[i].Name = cur.Device[i].Name
		u.Device[i].RBytes = cur.Device[i].RBytes - prof.prior.Device[i].RBytes
		u.Device[i].RPackets = cur.Device[i].RPackets - prof.prior.Device[i].RPackets
		u.Device[i].RErrs = cur.Device[i].RErrs - prof.prior.Device[i].RErrs
		u.Device[i].RDrop = cur.Device[i].RDrop - prof.prior.Device[i].RDrop
		u.Device[i].RFIFO = cur.Device[i].RFIFO - prof.prior.Device[i].RFIFO
		u.Device[i].RFrame = cur.Device[i].RFrame - prof.prior.Device[i].RFrame
		u.Device[i].RCompressed = cur.Device[i].RCompressed - prof.prior.Device[i].RCompressed
		u.Device[i].RMulticast = cur.Device[i].RMulticast - prof.prior.Device[i].RMulticast
		u.Device[i].TBytes = cur.Device[i].TBytes - prof.prior.Device[i].TBytes
		u.Device[i].TPackets = cur.Device[i].TPackets - prof.prior.Device[i].TPackets
		u.Device[i].TErrs = cur.Device[i].TErrs - prof.prior.Device[i].TErrs
		u.Device[i].TDrop = cur.Device[i].TDrop - prof.prior.Device[i].TDrop
		u.Device[i].TFIFO = cur.Device[i].TFIFO - prof.prior.Device[i].TFIFO
		u.Device[i].TColls = cur.Device[i].TColls - prof.prior.Device[i].TColls
		u.Device[i].TCarrier = cur.Device[i].TCarrier - prof.prior.Device[i].TCarrier
		u.Device[i].TCompressed = cur.Device[i].TCompressed - prof.prior.Device[i].TCompressed
	}
	return u
}
711250
func WithDummyInMemory(ctx context.Context) (context.Context, *monitor.Fake) {
	m := &monitor.Fake{}
	return WithState(ctx, &State{
		store:                        store.NewInMemory(&target.Task{}),
		monitor:                      m,
		invokeGlobalCallbacksOnFlush: true,
	}), m
}
585738
func (l *lru) CheckCache(mts []core.Metric, _ string) ([]core.Metric, []core.Metric) {
	return l.checkCache(mts)
}
398351
func (o *cacheOnce) cache(f func() error) {
	if atomic.LoadUint32(&o.done) == 1 {
		return
	}
	// Slow-path.
	o.m.Lock()
	defer o.m.Unlock()
	if o.done == 0 {
		err := f()
		if err == nil {
			atomic.StoreUint32(&o.done, 1)
		}
	}
}