// MemStats returns detailed runtime memory statistics.
345299
func (*HandlerT) MemStats() *runtime.MemStats {
	s := new(runtime.MemStats)
	runtime.ReadMemStats(s)
	return s
}
733985
func (c *Client) Stats() ClientStats {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	return c.stats
}
120562
func (p proc) GetMetrics() (Metrics, int, error) {
	counts, softerrors, err := p.GetCounts()
	if err != nil {
		return Metrics{}, 0, err
	}

	// We don't need to check for error here because p will have cached
	// the successful result of calling getStat in GetCounts.
	// Since GetMetrics isn't a pointer receiver method, our callers
	// won't see the effect of the caching between calls.
	stat, _ := p.getStat()

	// Ditto for states
	states, _ := p.GetStates()

	// Ditto for status
	status, _ := p.getStatus()

	numfds, err := p.Proc.FileDescriptorsLen()
	if err != nil {
		numfds = -1
		softerrors |= 1
	}

	limits, err := p.Proc.NewLimits()
	if err != nil {
		return Metrics{}, 0, err
	}

	wchan, err := p.getWchan()
	if err != nil {
		softerrors |= 1
	}

	return Metrics{
		Counts: counts,
		Memory: Memory{
			ResidentBytes: uint64(stat.ResidentMemory()),
			VirtualBytes:  uint64(stat.VirtualMemory()),
			VmSwapBytes:   uint64(status.VmSwapKB * 1024),
		},
		Filedesc: Filedesc{
			Open:  int64(numfds),
			Limit: uint64(limits.OpenFiles),
		},
		NumThreads: uint64(stat.NumThreads),
		States:     states,
		Wchan:      wchan,
	}, softerrors, nil
}
82605
func (e *Executor) VSchemaStats() *VSchemaStats {
	e.mu.Lock()
	defer e.mu.Unlock()
	if e.vschemaStats == nil {
		return &VSchemaStats{
			Error: "No VSchema loaded yet.",
		}
	}
	return e.vschemaStats
}
116966
func (d *FsDevice) stats(ctx context.Context, stats chan *device.StatsResponse, interval time.Duration) {
	defer close(stats)

	// Create a timer that will fire immediately for the first detection
	ticker := time.NewTimer(0)

	for {
		select {
		case <-ctx.Done():
			return
		case <-ticker.C:
			ticker.Reset(interval)
		}

		deviceStats, err := d.collectStats()
		if err != nil {
			stats <- &device.StatsResponse{
				Error: err,
			}
			return
		}
		if deviceStats == nil {
			continue
		}

		stats <- &device.StatsResponse{
			Groups: []*device.DeviceGroupStats{deviceStats},
		}
	}
}
1323914
func (v *ProcTableImpl) Stats() ProcTableStats {
	v.mutex.RLock()
	defer v.mutex.RUnlock()
	running := 0
	for _, entry := range v.procTable {
		if entry.Status == CSRunning {
			running++
		}
	}
	return ProcTableStats{
		Running:   running,
		Succeeded: v.succeeded,
		Failed:    v.failed,
	}
}
361099
func (s *systemInfo) MemTotal() (uint64, error) {
	memInfo, err := mem.VirtualMemory()
	if err != nil {
		return 0, err
	}
	return memInfo.Total, err
}
481258
func (it *Materialize) Stats() graph.IteratorStats {
	overhead := int64(2)
	var (
		size  int64
		exact bool
	)
	if it.expectSize > 0 {
		size, exact = it.expectSize, false
	} else {
		size, exact = it.Size()
	}
	subitStats := it.subIt.Stats()
	return graph.IteratorStats{
		ContainsCost: overhead * subitStats.NextCost,
		NextCost:     overhead * subitStats.NextCost,
		Size:         size,
		ExactSize:    exact,
		Next:         it.runstats.Next,
		Contains:     it.runstats.Contains,
	}
}
189985
func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 {
	return float64(mem.Usage - mem.Stats["cache"])
}
970964
func (m *manager) DeviceStats(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error) {
	// Go through each plugin and see if it has the requested devices
	for _, i := range m.instances {
		if !i.HasDevices(d) {
			continue
		}

		// We found a match so reserve
		return i.DeviceStats(d), nil
	}

	return nil, UnknownDeviceErrFromAllocated("failed to collect statistics", d)
}
397615
func DumpGoMemoryTrace() {
	m := &runtime.MemStats{}
	runtime.ReadMemStats(m)
	res := fmt.Sprintf("%#v", m)
	logrus.Infof("==== Dumping Memory Profile ===")
	logrus.Infof(res)
}
254336
func (c *CycleDB) Stats() Stats {
	ret := c.stats.AtomicClone()
	ret.SizeOfBacklogToCopy = len(c.readMovements)
	return ret
}
1045623
func (c *MiniClient) Statistics() MiniStats {
	c.bSwapLock.Lock()
	defer c.bSwapLock.Unlock()

	return unsyncStats(c.b)
}
29606
func (c *LRUCache) Stats() LRUCacheStats {
	defer func() {
		c.stats = LRUCacheStats{}
		c.mutex.Unlock()
	}()
	c.mutex.Lock()
	c.stats.Size = int64(len(c.cache))
	return c.stats
}
311804
func (e PrecisionTiming) Stats() []string {
	return []string{
		fmt.Sprintf("%s.count:%d|c", e.Name, e.Count),
		fmt.Sprintf("%s.avg:%.6f|ms", e.Name, float64(int64(e.Value)/e.Count)/1000000), // make sure e.Count != 0
		fmt.Sprintf("%s.min:%.6f|ms", e.Name, e.durationToMs(e.Min)),
		fmt.Sprintf("%s.max:%.6f|ms", e.Name, e.durationToMs(e.Max)),
	}
}
995102
func (r *Consumer) Stats() *ConsumerStats {
	return &ConsumerStats{
		MessagesReceived: atomic.LoadUint64(&r.messagesReceived),
		MessagesFinished: atomic.LoadUint64(&r.messagesFinished),
		MessagesRequeued: atomic.LoadUint64(&r.messagesRequeued),
		Connections:      len(r.conns()),
	}
}
184897
func (fs *FileSet) Stats() MeasurementCardinalityStats {
	stats := make(MeasurementCardinalityStats)
	mitr := fs.MeasurementIterator()
	if mitr == nil {
		return stats
	}

	for {
		// Iterate over each measurement and set cardinality.
		mm := mitr.Next()
		if mm == nil {
			return stats
		}

		// Obtain all series for measurement.
		sitr := fs.MeasurementSeriesIDIterator(mm.Name())
		if sitr == nil {
			continue
		}

		// All iterators should be series id set iterators except legacy 1.x data.
		// Skip if it does not conform as aggregation would be too slow.
		ssitr, ok := sitr.(tsdb.SeriesIDSetIterator)
		if !ok {
			continue
		}

		// Set cardinality for the given measurement.
		stats[string(mm.Name())] = int(ssitr.SeriesIDSet().Cardinality())
	}
}