Read power stats and return dictionary
515884
def rapl_read():
    
    basenames = glob.glob('/sys/class/powercap/intel-rapl:*/')
    basenames = sorted(set({x for x in basenames}))

    pjoin = os.path.join
    ret = list()
    for path in basenames:
        name = None
        try:
            name = cat(pjoin(path, 'name'), fallback=None, binary=False)
        except (IOError, OSError, ValueError) as err:
            logging.warning("ignoring %r for file %r",
                            (err, path), RuntimeWarning)
            continue
        if name:
            try:
                current = cat(pjoin(path, 'energy_uj'))
                max_reading = 0.0
                ret.append(RaplStats(name, float(current), max_reading))
            except (IOError, OSError, ValueError) as err:
                logging.warning("ignoring %r for file %r",
                                (err, path), RuntimeWarning)
    return ret
1197202
def stats(self):
        """"""
        load_count = self.last_level_load.MISS_count
        load_byte = self.last_level_load.MISS_byte

        if self.last_level_load.victims_to is not None:
            # If there is a victim cache between last_level and memory, subtract all victim hits
            load_count -= self.last_level_load.victims_to.HIT_count
            load_byte -= self.last_level_load.victims_to.HIT_byte

        return {'name': self.name,
                'LOAD_count': load_count,
                'LOAD_byte': load_byte,
                'HIT_count': load_count,
                'HIT_byte': load_byte,
                'STORE_count': self.last_level_store.EVICT_count,
                'STORE_byte': self.last_level_store.EVICT_byte,
                'EVICT_count': 0,
                'EVICT_byte': 0,
                'MISS_count': 0,
                'MISS_byte': 0}
487388
def stats(self):
        
        stats_online = CRef.cint()
        stats_ingame = CRef.cint()
        stats_chatting = CRef.cint()

        self._iface.get_clan_stats(
            self.group_id,
            stats_online,
            stats_ingame,
            stats_chatting,
        )

        return {
            'online': int(stats_online),
            'ingame': int(stats_ingame),
            'chatting': int(stats_chatting),
        }
1296557
def _iostats_dict(header, stats):
    '''
    
    '''
    stats = [float((sum(stat) / len(stat)).quantize(decimal.Decimal('.01'))) for stat in zip(*stats)]
    stats = dict(zip(header, stats))
    return stats
1048914
def stats():
    ''''''
    import re
    import sys
    import math
    values = []
    for line in sys.stdin:
        values.extend(map(float, re.findall(r'\d+\.?\d+', line)))

    mean = sum(values) / len(values)
    variance = sum((val - mean) ** 2 for val in values) / len(values)
    print '%3i items; mean: %10.5f; std-dev: %10.5f' % (
        len(values), mean, math.sqrt(variance))
794910
async def get_power_parameters_for(
            cls, system_ids: typing.Sequence[str]):
        
        if len(system_ids) == 0:
            return {}
        data = await cls._handler.power_parameters(id=system_ids)
        return data
1242344
def read_stat():
    
    return [
        {
            "times": {
                "user": random.randint(0, 999999999),
                "nice": random.randint(0, 999999999),
                "sys": random.randint(0, 999999999),
                "idle": random.randint(0, 999999999),
                "irq": random.randint(0, 999999999),
            }
        }
    ]
550931
def get_power(self):
        """"""
        self.get_status()
        try:
            self.consumption = self.data['power']
        except TypeError:
            self.consumption = 0

        return self.consumption
357684
def get_stats(self):
        """"""

        try:
            ret = fcntl.ioctl(self.ins, BIOCGSTATS, struct.pack("2I", 0, 0))
            return struct.unpack("2I", ret)
        except IOError:
            warning("Unable to get stats from BPF !")
            return (None, None)
1022972
def calc_signal_power(params, fname, transient=200, Df=None, mlab=True, NFFT=1000,
                      noverlap=0, window=plt.mlab.window_hanning):
    '''
    

    '''


    if type(fname) is str and os.path.isfile(fname):
        #open file
        f = h5py.File(fname)
        data = f['data'].value
        srate = f['srate'].value 
        tvec = np.arange(data.shape[1]) * 1000. / srate
        f.close()
    elif type(fname) is np.ndarray:
        data = fname
        srate = 1000.
        tvec = np.arange(data.shape[1]) * 1000. / srate
    else:
        raise Exception, '{} not a file or array'.format(fname)
    
    # slice
    slica = (tvec >= transient)
    data = data[:,slica]

    # subtract mean
    dataT = data.T - data.mean(axis=1)
    data = dataT.T
    
    #extract PSD
    PSD=[]
    for i in np.arange(len(params.electrodeParams['z'])):
        if mlab:
            Pxx, freqs=plt.mlab.psd(data[i], NFFT=NFFT,
                                    Fs=srate, noverlap=noverlap, window=window)
        else:
            [freqs, Pxx] = helpers.powerspec([data[i,]], tbin= 1.,
                                        Df=Df, pointProcess=False)
            mask = np.where(freqs >= 0.)
            freqs = freqs[mask]
            Pxx = Pxx.flatten()
            Pxx = Pxx[mask]
            Pxx = Pxx/tvec[tvec >= transient].size**2
        PSD +=[Pxx.flatten()]
        
    PSD=np.array(PSD)

    return freqs, PSD
106751
def stats():
    '''
    
    '''
    ret = {}
    cmd = 'locate -S'
    out = __salt__['cmd.run'](cmd).splitlines()
    for line in out:
        comps = line.strip().split()
        if line.startswith('Database'):
            ret['database'] = comps[1].replace(':', '')
            continue
        ret[' '.join(comps[1:])] = comps[0]
    return ret
146250
def stats():
    '''
    
    '''
    ret = {}
    out = __salt__['cmd.run']('quotastats').splitlines()
    for line in out:
        if not line:
            continue
        comps = line.split(': ')
        ret[comps[0]] = comps[1]

    return ret
1275601
def stats(self):
        
        return OrderedDict([
            ("Intervals", len(self.array)),
            ("Mean", self.format_time(self.mean or 0)),
            ("Min", self.format_time(self.min or 0)),
            ("Median", self.format_time(self.median or 0)),
            ("Max", self.format_time(self.max or 0)),
            ("St. Dev.", self.format_time(self.stdev or 0)),
            ("Total", self.format_time(self.exectime or 0)),
        ])
407310
def read_stats(self, *stats):
        

        self.statistics = OrderedDict()
        for port in self.ports:
            port_stats = IxeStatTotal(port).get_attributes(FLAG_RDONLY, *stats)
            port_stats.update({c + '_rate': v for c, v in
                               IxeStatRate(port).get_attributes(FLAG_RDONLY, *stats).items()})
            self.statistics[str(port)] = port_stats
        return self.statistics
232615
function getStats() {
  var procMem = process.memoryUsage();
  var stats = {
    mem: {
      total: os.totalmem(),
      free: os.freemem(),
      heap: procMem.rss
    },
    cpu: os.loadavg()
  };
  for(var i=0; i < stats.cpu.length; i++) {
    stats.cpu[i] = stats.cpu[i].toFixed(3);
  }
  stats.cpu = stats.cpu.join(",");
  // We convert from bytes to mb
  stats.mem.total = Math.ceil(stats.mem.total / 1000000) + "MB";
  stats.mem.free = Math.ceil(stats.mem.free / 1000000) + "MB";
  stats.mem.heap = (stats.mem.heap / 1000000).toFixed(3) + "MB";
  return stats;
}
354102
def to_dict(self):
        

        input_dict = super(RatQuad, self)._save_to_input_dict()
        input_dict["class"] = "GPy.kern.RatQuad"
        input_dict["power"] = self.power.values.tolist()
        return input_dict
337584
def get_power_state(self, userid):
        """"""
        LOG.debug('Querying power stat of %s' % userid)
        requestData = "PowerVM " + userid + " status"
        action = "query power state of '%s'" % userid
        with zvmutils.log_and_reraise_smt_request_failed(action):
            results = self._request(requestData)
        with zvmutils.expect_invalid_resp_data(results):
            status = results['response'][0].partition(': ')[2]
        return status