Skip to content

Commit

Permalink
temp fix for wrong visual metrics in the HAR #754 (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Feb 4, 2019
1 parent b8a6364 commit a6153a6
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions lib/core/engine/index.js
Expand Up @@ -32,24 +32,49 @@ function shouldDelay(index, total, delay) {
function addExtraFieldsToHar(totalResults, har, options) {
if (har) {
let harPageNumber = 0;
for (let harPage of har.log.pages) {
let pageNumber = harPageNumber % totalResults.length;
for (let iteration = 0; iteration < options.iterations; iteration++) {
const visualMetric = totalResults[pageNumber].visualMetrics[iteration];
// We test one page
// Let's do a better fix for this later on
// right now this fixes https://github.com/sitespeedio/browsertime/issues/754
if (har.log.pages.length === options.iterations) {
for (let harPage of har.log.pages) {
let pageNumber = harPageNumber % totalResults.length;
const visualMetric =
totalResults[pageNumber].visualMetrics[harPageNumber];
const browserScript =
totalResults[pageNumber].browserScripts[iteration];
const cpu = totalResults[pageNumber].cpu[iteration];
totalResults[pageNumber].browserScripts[harPageNumber];
const cpu = totalResults[pageNumber].cpu[harPageNumber];
harUtil.addExtrasToHAR(
iteration,
harPageNumber,
harPage,
visualMetric,
browserScript.timings,
cpu,
totalResults[pageNumber].info.url,
options
);
harPageNumber++;
}
} else {
for (let harPage of har.log.pages) {
let pageNumber = harPageNumber % totalResults.length;
for (let iteration = 0; iteration < options.iterations; iteration++) {
const visualMetric =
totalResults[pageNumber].visualMetrics[iteration];
const browserScript =
totalResults[pageNumber].browserScripts[iteration];
const cpu = totalResults[pageNumber].cpu[iteration];
harUtil.addExtrasToHAR(
harPageNumber,
harPage,
visualMetric,
browserScript.timings,
cpu,
totalResults[pageNumber].info.url,
options
);
}
harPageNumber++;
}
harPageNumber++;
}
}
}
Expand Down

0 comments on commit a6153a6

Please sign in to comment.