@best/analyzer
Advanced tools
@@ -23,7 +23,11 @@ "use strict"; | ||
// Given an iteration benchmark (whith nested benchmarks), collect its metrics | ||
function collectResults(resultNode, collector) { | ||
function collectResults(resultNode, collector, projectConfig) { | ||
const { name } = resultNode; | ||
let collectorNode = collector[name]; | ||
if (!collectorNode) { | ||
collectorNode = collector[name] = { script: [], aggregate: [], paint: [], layout: [] }; | ||
const emptyMetrics = projectConfig.metrics.reduce((acc, key) => ({ | ||
...acc, | ||
[key]: [] | ||
}), {}); | ||
collectorNode = collector[name] = emptyMetrics; | ||
} | ||
@@ -45,3 +49,3 @@ if (resultNode.aggregate > 0 && collectorNode.aggregate) { | ||
else { | ||
resultNode.nodes.forEach((node) => collectResults(node, collector)); | ||
resultNode.nodes.forEach((node) => collectResults(node, collector, projectConfig)); | ||
} | ||
@@ -76,3 +80,3 @@ return collector; | ||
// Collect the metrics for the nested benchmarks within | ||
const collector = results.reduce((reducer, node) => collectResults(node, reducer), {}); | ||
const collector = results.reduce((reducer, node) => collectResults(node, reducer, projectConfig), {}); | ||
// For each metric | ||
@@ -79,0 +83,0 @@ const benchmarkStats = Object.keys(collector).reduce((stats, benchmarkName) => { |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "4.0.0-alpha5", | ||
"version": "4.0.0-alpha6", | ||
"description": "Best Analyzer", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
], | ||
"gitHead": "9171538bbf3edaca3eb0b6f470b119a269b7779e" | ||
"gitHead": "790688e72822f83bdd0ccf304b522784fe35dd94" | ||
} |
7004
2.02%176
2.33%