/ Get Stats for the OT Plugin, newer than Chromes version, but still not in sync with the spec.
972020
function parseStatsOTPlugin (peerConnection,
                                                      prevStats,
                                                      currentStats,
                                                      completion) {

      var onStatsError = function onStatsError (error) {
            completion(error);
          },

          ///
          // From the Audio Tracks
          // * avgAudioBitrate
          // * audioBytesTransferred
          //
          parseAudioStats = function (statsReport) {
            var lastBytesSent = prevStats.audioBytesTransferred || 0,
                transferDelta;

            if (statsReport.audioInputLevel) {
              currentStats.audioSentBytes = Number(statsReport.bytesSent);
              currentStats.audioSentPackets = Number(statsReport.packetsSent);
              currentStats.audioSentPacketsLost = Number(statsReport.packetsLost);
              currentStats.audioRtt = Number(statsReport.googRtt);
              currentStats.audioCodec = statsReport.googCodecName;
            }
            else if (statsReport.audioOutputLevel) {
              currentStats.audioBytesTransferred = Number(statsReport.bytesReceived);
              currentStats.audioCodec = statsReport.googCodecName;
            }

            if (currentStats.audioBytesTransferred) {
              transferDelta = currentStats.audioBytesTransferred - lastBytesSent;
              currentStats.avgAudioBitrate = Math.round(transferDelta * 8 /
                (currentStats.period/1000));
            }
          },

          ///
          // From the Video Tracks
          // * frameRate
          // * avgVideoBitrate
          // * videoBytesTransferred
          //
          parseVideoStats = function (statsReport) {

            var lastBytesSent = prevStats.videoBytesTransferred || 0,
                transferDelta;

            if (statsReport.googFrameHeightSent) {
              currentStats.videoSentBytes = Number(statsReport.bytesSent);
              currentStats.videoSentPackets = Number(statsReport.packetsSent);
              currentStats.videoSentPacketsLost = Number(statsReport.packetsLost);
              currentStats.videoRtt = Number(statsReport.googRtt);
              currentStats.videoCodec = statsReport.googCodecName;
              currentStats.videoWidth = Number(statsReport.googFrameWidthSent);
              currentStats.videoHeight = Number(statsReport.googFrameHeightSent);
            }
            else if (statsReport.googFrameHeightReceived) {
              currentStats.videoRecvBytes =   Number(statsReport.bytesReceived);
              currentStats.videoRecvPackets = Number(statsReport.packetsReceived);
              currentStats.videoRecvPacketsLost = Number(statsReport.packetsLost);
              currentStats.videoRtt = Number(statsReport.googRtt);
              currentStats.videoCodec = statsReport.googCodecName;
              currentStats.videoWidth = Number(statsReport.googFrameWidthReceived);
              currentStats.videoHeight = Number(statsReport.googFrameHeightReceived);
            }

            if (currentStats.videoBytesTransferred) {
              transferDelta = currentStats.videoBytesTransferred - lastBytesSent;
              currentStats.avgVideoBitrate = Math.round(transferDelta * 8 /
               (currentStats.period/1000));
            }

            if (statsReport.googFrameRateSent) {
              currentStats.videoFrameRate = Number(statsReport.googFrameRateSent);
            } else if (statsReport.googFrameRateReceived) {
              currentStats.videoFrameRate = Number(statsReport.googFrameRateReceived);
            }
          },

          isStatsForVideoTrack = function(statsReport) {
            return statsReport.googFrameHeightSent !== void 0 ||
                    statsReport.googFrameHeightReceived !== void 0 ||
                    currentStats.videoBytesTransferred !== void 0 ||
                    statsReport.googFrameRateSent !== void 0;
          },

          isStatsForIceCandidate = function(statsReport) {
            return statsReport.googActiveConnection === 'true';
          };

      peerConnection.getStats(null, function(statsReports) {
        statsReports.forEach(function(statsReport) {
          if (isStatsForIceCandidate(statsReport)) {
            currentStats.localCandidateType = statsReport.googLocalCandidateType;
            currentStats.remoteCandidateType = statsReport.googRemoteCandidateType;
            currentStats.transportType = statsReport.googTransportType;
          }
          else if (isStatsForVideoTrack(statsReport)) {
            parseVideoStats(statsReport);
          }
          else {
            parseAudioStats(statsReport);
          }
        });

        completion(null, currentStats);
      }, onStatsError);
    }
988989
def getAllAsDict(self):
        """"""
        return {p: self._plugins[p].get_raw() for p in self._plugins}
572249
function getStats(results) {

  /**
   * calculate stats for each severity
   * @param {string} type  severity
   * @returns {Object} stats
   */
  function filterMessages(type) {
    return lodash(results)
      .map('messages')
      .flatten()
      .filter(function (message) { return message.severity === type; })
      .groupBy('ruleId')
      .mapValues(function (ruleMessages) {
        return ruleMessages.length;
      })
      .value();
  }
  return {
    errors: filterMessages(2),
    warnings: filterMessages(1)
  };
}
923285
def get_plugins_info(self, limit=10, offset=10):
        
        params = {}
        if offset:
            params['offset'] = offset
        if limit:
            params['limit'] = limit
        url = 'rest/1.0/plugins'
        return (self.get(url, params=params) or {}).get('plugins')
401458
def get_stats(self):
        
        try:
            query = {
                # We only care about the aggregations, so don't return the hits
                'size': 0,
                'aggs': {
                    'num_packages': {
                        'value_count': {
                            'field': 'id',
                        },
                    },
                    'num_records': {
                        'sum': {
                            'field': 'package.count_of_rows',
                        },
                    },
                    'num_countries': {
                        'cardinality': {
                            'field': 'package.countryCode.keyword',
                        },
                    },
                },
            }
            aggregations = self.es.search(index=self.index_name,
                                          body=query)['aggregations']

            return {
                key: int(value['value'])
                for key, value in aggregations.items()
            }
        except NotFoundError:
            return {}
756128
function getScore (stats) {
    return calc.aggregate([TITLE_W, COMPETITOR_W, INSTALLS_W, RATING_W, AGE_W],
                          [stats.titleMatches.score, stats.competitors.score,
                           stats.installs.score, stats.rating.score, stats.age.score]);
  }
1023531
function stat (archive, name, cb) {
  return maybe(cb, new Promise((resolve, reject) => {
    // run stat operation
    archive.stat(name, (err, st) => {
      if (err) reject(toBeakerError(err, 'stat'))
      else {
        // read download status
        st.downloaded = 0
        if (!archive.key) {
          // fs, not an archive
          st.downloaded = st.blocks
        } else if (st.isFile()) {
          if (archive.content && archive.content.length) {
            st.downloaded = archive.content.downloaded(st.offset, st.offset + st.blocks)
          }
        }
        resolve(st)
      }
    })
  }))
}
176216
async def get(self):
        """"""

        context_data = self.get_context_data()
        context_data.update(getattr(self.request.app, "stats", {}))

        response = self.json_response(context_data)
        return response
484719
def overview(self, tag=None, fromdate=None, todate=None):
        
        return self.call("GET", "/stats/outbound", tag=tag, fromdate=fromdate, todate=todate)
145101
def instance_get(plugin, opts, url_file_input, out):
    
    inst = plugin()
    hp, func, enabled_func = inst._general_init(opts, out)
    name = inst._meta.label

    kwargs = {
        'hide_progressbar': hp,
        'functionality': func,
        'enabled_functionality': enabled_func
    }

    if url_file_input:
        del kwargs['hide_progressbar']

    return {
        'inst': inst,
        'kwargs': kwargs
    }
1238638
function getChromeDriverVersion() {
  return new Promise(resolve => {
    const defaultVersion = 'latest';

    matcher.getChromeDriverVersion()
      .then(result => {
        if (result.chromeDriverVersion) {
          resolve(result.chromeDriverVersion);
        } else {
          resolve(defaultVersion);
        }
      })
      .catch(() => resolve(defaultVersion));
  });
}
68439
def get_stats(self, request, context):
        """"""
        _log_request(request, context)
        m = self.listener.memory
        return clearly_pb2.StatsMessage(
            task_count=m.task_count,
            event_count=m.event_count,
            len_tasks=len(m.tasks),
            len_workers=len(m.workers)
        )
462981
def plugin_counts(self):
        
        ret = {
            'total': 0,
        }

        # As ususal, we need data before we can actually do anything ;)
        data = self.raw_query('plugin', 'init')

        # For backwards compatability purposes, we will be handling this a bit
        # differently than I would like.  We are going to check to see if each
        # value exists and override the default value of 0.  The only value that
        # I know existed in bost 4.2 and 4.4 is pluginCount, the rest aren't
        # listed in the API docs, however return back from my experimentation.
        ret['total'] = data['pluginCount']

        if 'lastUpdates' in data:
            for item in ['active', 'passive', 'compliance', 'custom', 'event']:
                itemdata = {}
                if item in data['lastUpdates']:
                    itemdata = data['lastUpdates'][item]
                if item in data:
                    itemdata['count'] = data[item]
                else:
                    itemdata['count'] = 0

                ret[item] = itemdata
        return ret
1368137
function getPerformanceTimingData() {
        var PerformanceObj = {
            'redirecting': performance.timing.fetchStart - performance.timing.navigationStart,
            'dnsconnect': performance.timing.requestStart - performance.timing.fetchStart,
            'request': performance.timing.responseStart - performance.timing.requestStart,
            'response': performance.timing.responseEnd - performance.timing.responseStart,
            'domprocessing': performance.timing.domComplete - performance.timing.responseEnd,
            'load': performance.timing.loadEventEnd - performance.timing.loadEventStart
        };

        /**
         * Obtaining the transferred kb of resources inluding estimated document size.
         */
        if (window.performance && window.performance.getEntriesByType) {
            var resource;
            var resources = window.performance.getEntriesByType('resource');
            var documentSize = unescape(encodeURIComponent(document.documentElement.innerHTML)).length / 4.2;
            var byteTotal = 0;
            for (var i = 0; i < resources.length; i++) {
                resource = resources[i];
                byteTotal = byteTotal + resource.transferSize;
            }
            PerformanceObj.transferbytes = byteTotal + Math.round(documentSize);
            PerformanceObj.transferrequests = resources.length + 1;
        }

        return PerformanceObj;
    }
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;
}
838856
function getHeapStatistics(unitInfo) {
  const data = v8.getHeapStatistics();
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((key) => {
    result[key] = format(data[key], unitInfo);
  });
  return result;
}
554442
function queryPluginVersion(pluginDir) {
        var pluginXml = path.join(pluginDir, 'plugin.xml');

        var domPluginXml = jsdom.jsdom(fs.readFileSync(pluginXml).toString());
        return $(domPluginXml).find('plugin').attr('version');
    }