Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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]]));
}
}
});
});
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();
}
getCacheTimeStats: function(components) {
var stats = new Stats();
var self = this;
components.forEach(function(comp) {
stats.push(self.getCacheTime(comp));
});
return util.getStatisticsObject(stats, 0);
},
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);
}
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),
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]);
}
}
};
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);
}
});
}
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();
}
timeMetrics.forEach(function(metric) {
self[metric] = new Stats();
});
this.runs = [];
options.metrics.forEach(fieldName => {
aggregateRow[fieldName] = new Stats();
});
out[key] = aggregateRow;