How to use fast-stats - 10 common examples

To help you get started, we’ve selected a few fast-stats examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sitespeedio / sitespeed.io / lib / aggregators / har / genericTimeMetric.js View on Github external
har.log.entries.forEach(function(entry) {
      // TODO verify that timings really exists
      var timings = Object.keys(entry.timings);

      for (var i = 0; i < timings.length; i++) {
        if (timings[i] === 'comment') {
          continue;
        }
        if (timeMetrics.hasOwnProperty(timings[i])) {
          timeMetrics[timings[i]].push(Number(entry.timings[timings[i]]));
        } else {
          timeMetrics[timings[i]] = new Stats();
          timeMetrics[timings[i]].push(Number(entry.timings[timings[i]]));
        }
      }
    });
  });
github sitespeedio / sitespeed.io / lib / aggregators / wptMetric.js View on Github external
function WPTMetric(metricName, view, location, browser, connectivity) {
  this.view = view;
  this.location = location;
  this.browser = (browser !== undefined) ? browser.replace(' ', '_'): browser;
  this.connectivity = connectivity;
  this.metricName = metricName;

  // decide if it's a summary independent of browsers etcs
  if (location && connectivity && browser) {
    this.key = location + '.' + connectivity + '.' + browser + '.' + view + '.' + metricName;
  } else {
    this.key = view + '.' + metricName;
  }

  this.stats = new Stats();
}
github sitespeedio / sitespeed.io / lib / util / yslowUtil.js View on Github external
getCacheTimeStats: function(components) {
    var stats = new Stats();
    var self = this;
    components.forEach(function(comp) {
      stats.push(self.getCacheTime(comp));
    });

    return util.getStatisticsObject(stats, 0);
  },
github sitespeedio / browsertime / lib / support / statistics.js View on Github external
add(key, value) {
    validateType(key, 'string', 'key (' + key + ') must be a string');
    validateType(value, 'number', 'value (' + value + ') must be a number');
    if (!isFinite(value)) {
      throw new RangeError("value can't be infinite");
    }

    let stats = this.data[key] || new Stats();
    this.data[key] = stats.push(value);
  }
github tsouza / yajs / src / bench / bench.ts View on Github external
return new Promise((resolve, reject) => {
        const stats = new Stats();
        const child = fork(`./bench-${bench}.ts`, [], {
            env: { DATA: `${dataset}`, JSON_PATH: path, TYPE: type },
        }).
        on('message', (m) => {
            if (m.end) {
                completed = true;
                stats.push(m.rate.currentRate);
                const eps = stats.amean();
                let drop;
                if (bench === 'yajs') {
                    drop = '-';
                    table._base = eps;
                } else {
                    drop = (((table._base / eps) - 1) * 100).toFixed(2) + '%';
                }
                table.addRow(bench, 'Yes', time(new Date().getTime() - start),
github sitespeedio / browsertime / lib / statistics.js View on Github external
exports.setupStatistics = function(timings, metric, name) {
    if (metric[name]) {
        if (timings[name]) {
            timings[name].push(metric[name]);
        } else {
            timings[name] = new Stats().push(metric[name]);
        }
    }
};
github sitespeedio / sitespeed.io / lib / headless / headlessTiming.js View on Github external
headlessTimings.userTimings.marks.forEach(function(mark) {
      if (self.hasOwnProperty(mark.name)) {
        self[mark.name].push(mark.startTime);
      } else {
        self[mark.name] = new Stats().push(mark.startTime);
        timeMetrics.push(mark.name);
      }
    });
  }
github sitespeedio / sitespeed.io / lib / aggregators / aggregator.js View on Github external
function Aggregator(id, title, description, type, unit, decimals, processPage) {
  this.id = id;
  this.title = title;
  this.description = description;
  this.type = type;
  this.decimals = decimals;
  this.unit = unit;
  this.processPage = processPage;
  this.key = id;
  this.stats = new Stats();
}
github sitespeedio / sitespeed.io / lib / headless / headlessTiming.js View on Github external
timeMetrics.forEach(function(metric) {
    self[metric] = new Stats();
  });
  this.runs = [];
github Financial-Times / polyfill-service / service / RumReport.js View on Github external
options.metrics.forEach(fieldName => {
							aggregateRow[fieldName] = new Stats();
						});
						out[key] = aggregateRow;

fast-stats

Quickly calculate common statistics on lists of numbers

Apache-2.0
Latest version published 4 months ago

Package Health Score

69 / 100
Full package analysis

Popular fast-stats functions